@shushed/helpers 0.0.198-v2-20251117111213 → 0.0.198-v2-20251119102051
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dist-dereferenced/asset.js +1 -1
- package/dist/cjs/dist-dereferenced/development-colour.js +1 -1
- package/dist/cjs/src-public/airtable.js +13 -2
- package/dist/types/dist-dereferenced/asset.d.ts +17 -0
- package/dist/types/dist-dereferenced/development-colour.d.ts +17 -0
- package/dist/types/dist-types/asset.d.ts +7 -0
- package/dist/types/dist-types/development-colour.d.ts +7 -0
- package/dist/types/src-public/airtable.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Asset", "type": "object", "additionalProperties": false, "properties": { "source_url": { "type": "string" }, "last_modified_at": { "type": "string", "format": "date-time" }, "width": { "type": "integer", "minimum": 0 }, "height": { "type": "integer", "minimum": 0 }, "content_type": { "type": "string", "pattern": "^[a-z0-9-/]+$" }, "file_name": { "type": "string", "pattern": "^[a-z0-9-.]+$" } }, "required": ["source_url", "content_type", "last_modified_at"], "$id": "https://shushed.example.com/asset.json" };
|
|
3
|
+
const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Asset", "type": "object", "additionalProperties": false, "properties": { "product_id": { "type": "string" }, "dash_id": { "type": "string" }, "dash_folder_path": { "type": "string" }, "source_url": { "type": "string" }, "created_at": { "type": "string", "format": "date-time" }, "last_modified_at": { "type": "string", "format": "date-time" }, "width": { "type": "integer", "minimum": 0 }, "height": { "type": "integer", "minimum": 0 }, "meta": { "type": "object", "additionalProperties": true }, "content_type": { "type": "string", "pattern": "^[a-z0-9-/]+$" }, "file_name": { "type": "string", "pattern": "^[a-z0-9-.]+$" } }, "required": ["source_url", "content_type", "last_modified_at"], "$id": "https://shushed.example.com/asset.json" };
|
|
4
4
|
exports.default = schema;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Development Colour", "type": "object", "additionalProperties": false, "properties": { "colour_id": { "type": "string" }, "name": { "type": ["string", "null"] }, "rgb": { "anyOf": [{ "type": "null" }, { "type": "array", "items": { "type": "number" } }] }, "cmyk": { "anyOf": [{ "type": "null" }, { "type": "array", "items": { "type": "number" } }] }, "pantone": { "anyOf": [{ "type": "null" }, { "type": "object", "properties": { "name": { "type": "string" }, "system": { "type": "string", "pattern": "^[A-Z0-9-]+$" }, "id": { "type": "string", "pattern": "^[A-Z0-9-]+$" } } }] }, "display_name": { "type": ["string", "null"], "pattern": "^[ a-z-]+$" }, "family_display_name": { "type": ["string", "null"], "pattern": "^[ a-z]+$" }, "source_asset": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Asset", "type": "object", "additionalProperties": false, "properties": { "source_url": { "type": "string" }, "last_modified_at": { "type": "string", "format": "date-time" }, "width": { "type": "integer", "minimum": 0 }, "height": { "type": "integer", "minimum": 0 }, "content_type": { "type": "string", "pattern": "^[a-z0-9-/]+$" }, "file_name": { "type": "string", "pattern": "^[a-z0-9-.]+$" } }, "required": ["source_url", "content_type", "last_modified_at"] } }, "required": ["colour_id"], "$id": "https://shushed.example.com/development-colour.schema.json" };
|
|
3
|
+
const schema = { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Development Colour", "type": "object", "additionalProperties": false, "properties": { "colour_id": { "type": "string" }, "name": { "type": ["string", "null"] }, "rgb": { "anyOf": [{ "type": "null" }, { "type": "array", "items": { "type": "number" } }] }, "cmyk": { "anyOf": [{ "type": "null" }, { "type": "array", "items": { "type": "number" } }] }, "pantone": { "anyOf": [{ "type": "null" }, { "type": "object", "properties": { "name": { "type": "string" }, "system": { "type": "string", "pattern": "^[A-Z0-9-]+$" }, "id": { "type": "string", "pattern": "^[A-Z0-9-]+$" } } }] }, "display_name": { "type": ["string", "null"], "pattern": "^[ a-z-]+$" }, "family_display_name": { "type": ["string", "null"], "pattern": "^[ a-z]+$" }, "source_asset": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Asset", "type": "object", "additionalProperties": false, "properties": { "product_id": { "type": "string" }, "dash_id": { "type": "string" }, "dash_folder_path": { "type": "string" }, "source_url": { "type": "string" }, "created_at": { "type": "string", "format": "date-time" }, "last_modified_at": { "type": "string", "format": "date-time" }, "width": { "type": "integer", "minimum": 0 }, "height": { "type": "integer", "minimum": 0 }, "meta": { "type": "object", "additionalProperties": true }, "content_type": { "type": "string", "pattern": "^[a-z0-9-/]+$" }, "file_name": { "type": "string", "pattern": "^[a-z0-9-.]+$" } }, "required": ["source_url", "content_type", "last_modified_at"] } }, "required": ["colour_id"], "$id": "https://shushed.example.com/development-colour.schema.json" };
|
|
4
4
|
exports.default = schema;
|
|
@@ -49,6 +49,7 @@ class AirtableHelper extends runtime_1.default {
|
|
|
49
49
|
}) {
|
|
50
50
|
let response = null;
|
|
51
51
|
const tableUrl = `https://api.airtable.com/v0/${this.baseId}/${this.tableId}`;
|
|
52
|
+
const currentBatch = payload.slice(callIdx * 10, (callIdx + 1) * 10);
|
|
52
53
|
try {
|
|
53
54
|
response = await fetch(`${tableUrl}`, {
|
|
54
55
|
method: "PATCH",
|
|
@@ -61,7 +62,7 @@ class AirtableHelper extends runtime_1.default {
|
|
|
61
62
|
fieldsToMergeOn: (options.fieldsToMergeOn ?? [this.primaryKeyFieldName]).map(x => this.dictionary[x] || x),
|
|
62
63
|
},
|
|
63
64
|
returnFieldsByFieldId: true,
|
|
64
|
-
records:
|
|
65
|
+
records: currentBatch.map(x => ({
|
|
65
66
|
fields: AirtableHelper.convertToDictionary(this.dictionary, this.primaryKeyWritable === false ? AirtableHelper.removePrimaryKey(x, this.primaryKeyFieldName) : x),
|
|
66
67
|
}))
|
|
67
68
|
}),
|
|
@@ -82,7 +83,17 @@ class AirtableHelper extends runtime_1.default {
|
|
|
82
83
|
return nextCollectedResult;
|
|
83
84
|
}
|
|
84
85
|
catch (err) {
|
|
85
|
-
|
|
86
|
+
const errorMessage = `Failed to update records in ${this.tableId} table (baseId: ${this.baseId}). Status: ${response?.status || 'unknown'}. Error: ${err.message}`;
|
|
87
|
+
const batchErrors = currentBatch.map(() => new Error(errorMessage));
|
|
88
|
+
const nextCollectedResult = {
|
|
89
|
+
updatedRecords: collectedResult.updatedRecords,
|
|
90
|
+
createdRecords: collectedResult.createdRecords,
|
|
91
|
+
records: collectedResult.records.concat(batchErrors)
|
|
92
|
+
};
|
|
93
|
+
if (payload.length > (callIdx + 1) * 10) {
|
|
94
|
+
return this.updateMultiple(payload, options, callIdx + 1, nextCollectedResult);
|
|
95
|
+
}
|
|
96
|
+
return nextCollectedResult;
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
99
|
async upsert(payload) {
|
|
@@ -4,9 +4,22 @@ declare const schema: {
|
|
|
4
4
|
readonly type: "object";
|
|
5
5
|
readonly additionalProperties: false;
|
|
6
6
|
readonly properties: {
|
|
7
|
+
readonly product_id: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
};
|
|
10
|
+
readonly dash_id: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
};
|
|
13
|
+
readonly dash_folder_path: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
};
|
|
7
16
|
readonly source_url: {
|
|
8
17
|
readonly type: "string";
|
|
9
18
|
};
|
|
19
|
+
readonly created_at: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
readonly format: "date-time";
|
|
22
|
+
};
|
|
10
23
|
readonly last_modified_at: {
|
|
11
24
|
readonly type: "string";
|
|
12
25
|
readonly format: "date-time";
|
|
@@ -19,6 +32,10 @@ declare const schema: {
|
|
|
19
32
|
readonly type: "integer";
|
|
20
33
|
readonly minimum: 0;
|
|
21
34
|
};
|
|
35
|
+
readonly meta: {
|
|
36
|
+
readonly type: "object";
|
|
37
|
+
readonly additionalProperties: true;
|
|
38
|
+
};
|
|
22
39
|
readonly content_type: {
|
|
23
40
|
readonly type: "string";
|
|
24
41
|
readonly pattern: "^[a-z0-9-/]+$";
|
|
@@ -64,9 +64,22 @@ declare const schema: {
|
|
|
64
64
|
readonly type: "object";
|
|
65
65
|
readonly additionalProperties: false;
|
|
66
66
|
readonly properties: {
|
|
67
|
+
readonly product_id: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
};
|
|
70
|
+
readonly dash_id: {
|
|
71
|
+
readonly type: "string";
|
|
72
|
+
};
|
|
73
|
+
readonly dash_folder_path: {
|
|
74
|
+
readonly type: "string";
|
|
75
|
+
};
|
|
67
76
|
readonly source_url: {
|
|
68
77
|
readonly type: "string";
|
|
69
78
|
};
|
|
79
|
+
readonly created_at: {
|
|
80
|
+
readonly type: "string";
|
|
81
|
+
readonly format: "date-time";
|
|
82
|
+
};
|
|
70
83
|
readonly last_modified_at: {
|
|
71
84
|
readonly type: "string";
|
|
72
85
|
readonly format: "date-time";
|
|
@@ -79,6 +92,10 @@ declare const schema: {
|
|
|
79
92
|
readonly type: "integer";
|
|
80
93
|
readonly minimum: 0;
|
|
81
94
|
};
|
|
95
|
+
readonly meta: {
|
|
96
|
+
readonly type: "object";
|
|
97
|
+
readonly additionalProperties: true;
|
|
98
|
+
};
|
|
82
99
|
readonly content_type: {
|
|
83
100
|
readonly type: "string";
|
|
84
101
|
readonly pattern: "^[a-z0-9-/]+$";
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
export interface __MainSchema {
|
|
2
|
+
product_id?: string;
|
|
3
|
+
dash_id?: string;
|
|
4
|
+
dash_folder_path?: string;
|
|
2
5
|
source_url: string;
|
|
6
|
+
created_at?: string;
|
|
3
7
|
last_modified_at: string;
|
|
4
8
|
width?: number;
|
|
5
9
|
height?: number;
|
|
10
|
+
meta?: {
|
|
11
|
+
[k: string]: unknown;
|
|
12
|
+
};
|
|
6
13
|
content_type: string;
|
|
7
14
|
file_name?: string;
|
|
8
15
|
}
|
|
@@ -14,10 +14,17 @@ export interface __MainSchema {
|
|
|
14
14
|
source_asset?: Asset;
|
|
15
15
|
}
|
|
16
16
|
export interface Asset {
|
|
17
|
+
product_id?: string;
|
|
18
|
+
dash_id?: string;
|
|
19
|
+
dash_folder_path?: string;
|
|
17
20
|
source_url: string;
|
|
21
|
+
created_at?: string;
|
|
18
22
|
last_modified_at: string;
|
|
19
23
|
width?: number;
|
|
20
24
|
height?: number;
|
|
25
|
+
meta?: {
|
|
26
|
+
[k: string]: unknown;
|
|
27
|
+
};
|
|
21
28
|
content_type: string;
|
|
22
29
|
file_name?: string;
|
|
23
30
|
}
|
|
@@ -46,7 +46,7 @@ declare class AirtableHelper<T extends Record<string, string>, K extends keyof T
|
|
|
46
46
|
fields: {
|
|
47
47
|
[key in T[keyof T]]: any;
|
|
48
48
|
};
|
|
49
|
-
}>;
|
|
49
|
+
} | Error>;
|
|
50
50
|
}): Promise<{
|
|
51
51
|
updatedRecords: Array<string>;
|
|
52
52
|
createdRecords: Array<string>;
|
|
@@ -55,7 +55,7 @@ declare class AirtableHelper<T extends Record<string, string>, K extends keyof T
|
|
|
55
55
|
fields: {
|
|
56
56
|
[key in T[keyof T]]: any;
|
|
57
57
|
};
|
|
58
|
-
}>;
|
|
58
|
+
} | Error>;
|
|
59
59
|
}>;
|
|
60
60
|
upsert(payload: Partial<{
|
|
61
61
|
[key in keyof T]: any;
|