Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ out/
*.d.ts.map
*.js.map
*.d.ts
!src/types/setup-index-module.d.ts
!src/setup/index.d.ts

# ESLint cache
.eslintcache
Expand Down
2 changes: 2 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ fileignoreconfig:
checksum: e71ec7cc7cfc72cd7f87ce90c3538914ce571788872c00a009a3221dd5b876ef
- filename: src/setup/__tests__/index.test.js
checksum: bfe9d72867ce3255060c5b494460c04f89fba2f2f513f6fdaf053624d9742119
- filename: src/setup/index.d.ts
checksum: 9369a9bb34c12addfdae51d7d7a6bffdf7a3d8dd93635b3de7950db04dbf958b
version: "1.0"
112 changes: 112 additions & 0 deletions src/setup/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// TypeScript declarations for setup/index.js

export interface ContentType {
uid: string;
schema: FieldSchema[];
[key: string]: unknown;
}

export interface FieldSchema {
uid: string;
data_type: string;
multiple?: boolean;
blocks?: unknown[];
reference_to?: string;
[key: string]: unknown;
}

export interface Entry {
uid: string;
_content_type_uid: string;
_metadata?: {
uid: string;
[key: string]: unknown;
};
[key: string]: unknown;
}

export interface Asset {
uid: string;
url: string;
filename: string;
_metadata?: {
extensions?: Record<string, unknown>;
[key: string]: unknown;
};
[key: string]: unknown;
}

export interface MetaobjectEntries {
[type: string]: {
[path: string]: {
id?: string;
_field_type?: string;
values?: unknown[];
toJSON(): unknown;
[key: string]: unknown;
};
};
}

export interface UpdatedProductMetafields {
[key: string]: {
value: unknown;
toJSON(): unknown;
system?: unknown;
};
}

export interface UpdatedMetaobject {
currentMetaobjects: unknown;
dataCSLPMapping: Record<string, unknown>;
}

export interface ShopifyFieldsOptions {
[key: string]: unknown;
}

export interface KeyBasedContentType {
[fieldUid: string]: FieldSchema;
}

export declare function fetchData(
ctUID: string,
entryUID: string,
hash: string,
locale: string
): Promise<unknown>;

export declare function createMetaobjectEntries(
contentType: ContentType | FieldSchema,
entries: Entry[],
type: string,
path: string,
entryMetaObject: MetaobjectEntries,
dataCSLPMapping: Record<string, unknown>,
extraData: unknown
): Promise<unknown[]>;

export declare function getUpdatedProductMetafields(
currentMetafields: unknown,
keyBasedCt: KeyBasedContentType,
entry: Entry,
options: {
ctUid: string;
entryUid: string;
hash: string;
}
): Promise<UpdatedProductMetafields>;

export declare function getUpdatedMetaobject(
currentMetaobjects: unknown,
keyBasedCt: KeyBasedContentType,
entry: Entry,
options: {
ctUid: string;
hash: string;
}
): Promise<UpdatedMetaobject>;

export declare function createContentTypeKeyBased(
contentType: FieldSchema[]
): KeyBasedContentType;
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"allowJs": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
Expand Down