From 0432a6110e4c9abd300d7d113fd89eb6ecf914a6 Mon Sep 17 00:00:00 2001 From: Stephen Heindel Date: Fri, 20 Oct 2023 10:10:52 -0400 Subject: [PATCH 1/9] Fix FieldValue for lookup field --- src/field_set.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/field_set.ts b/src/field_set.ts index 8a5e79c6..110df5e5 100644 --- a/src/field_set.ts +++ b/src/field_set.ts @@ -1,14 +1,7 @@ import {Collaborator} from './collaborator'; import {Attachment} from './attachment'; +export type FieldValue = string | number | boolean | Collaborator | ReadonlyArray | ReadonlyArray | ReadonlyArray | ReadonlyArray; export interface FieldSet { - [key: string]: - | undefined - | string - | number - | boolean - | Collaborator - | ReadonlyArray - | ReadonlyArray - | ReadonlyArray; + [key: string]: FieldValue; } From 32328a1af3b1e039ec49012e417f598d8b57b249 Mon Sep 17 00:00:00 2001 From: Stephen Heindel Date: Fri, 20 Oct 2023 16:00:20 -0400 Subject: [PATCH 2/9] Add several missing types, major types update --- package-lock.json | 2 +- src/barcode.ts | 4 ++++ src/button.ts | 4 ++++ src/collaborator.ts | 5 +++-- src/field_set.ts | 38 +++++++++++++++++++++++++++++++++++++- src/sync_source.ts | 5 +++++ 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 src/barcode.ts create mode 100644 src/button.ts create mode 100644 src/sync_source.ts diff --git a/package-lock.json b/package-lock.json index 85c84689..24724a1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "airtable", - "version": "0.12.1", + "version": "0.12.2", "license": "MIT", "dependencies": { "@types/node": ">=8.0.0 <15", diff --git a/src/barcode.ts b/src/barcode.ts new file mode 100644 index 00000000..aadc06d2 --- /dev/null +++ b/src/barcode.ts @@ -0,0 +1,4 @@ +export interface Barcode { + type?: string; + text?: string; +} \ No newline at end of file diff --git a/src/button.ts b/src/button.ts new file mode 100644 index 00000000..e722160b --- /dev/null +++ b/src/button.ts @@ -0,0 +1,4 @@ +export interface Button { + label: string; + url?: string; +} \ No newline at end of file diff --git a/src/collaborator.ts b/src/collaborator.ts index 932fa8bb..aff87208 100644 --- a/src/collaborator.ts +++ b/src/collaborator.ts @@ -1,5 +1,6 @@ export interface Collaborator { id: string; - email: string; - name: string; + email?: string; + name?: string; + profilePicUrl?: string; } diff --git a/src/field_set.ts b/src/field_set.ts index 110df5e5..45265b6e 100644 --- a/src/field_set.ts +++ b/src/field_set.ts @@ -1,7 +1,43 @@ import {Collaborator} from './collaborator'; import {Attachment} from './attachment'; +import {Barcode} from './barcode'; +import {Button} from './button'; +import { SyncSource } from './sync_source'; -export type FieldValue = string | number | boolean | Collaborator | ReadonlyArray | ReadonlyArray | ReadonlyArray | ReadonlyArray; +// AI Text +// Attachment: Attachment +// Auto number: number +// Barcode: Barcode +// Button: Button +// Checkbox: boolean +// Collaborator: Collaborator +// Count: number +// Created by: Collaborator +// Created time: string +// Currency: number +// Date: string +// Date and time: string +// Duration: number +// Email: string +// Formula: string | number +// Last modified by: +// Last modified time: string +// Link to another record: string[] +// Long text: string +// Lookup: FieldValue[] +// Multiple collaborator: Collaborator[] +// Multiple select: string[] +// Number: number +// Percent: number +// Phone: string +// Rating: number +// Rich text: string +// Rollup: FieldValue (string[], number[], string) +// Single line text: string +// Single select: string +// Sync source: SyncSource +// Url: string +export type FieldValue = string | number | boolean | Collaborator | SyncSource | ReadonlyArray | ReadonlyArray; export interface FieldSet { [key: string]: FieldValue; } diff --git a/src/sync_source.ts b/src/sync_source.ts new file mode 100644 index 00000000..71364811 --- /dev/null +++ b/src/sync_source.ts @@ -0,0 +1,5 @@ +export interface SyncSource { + id: string; + name: string; + color?: string; +} \ No newline at end of file From 7b0b8833ebc93830bfc3bbc5fad3ff5e046b2f3b Mon Sep 17 00:00:00 2001 From: Stephen Heindel Date: Fri, 20 Oct 2023 16:02:44 -0400 Subject: [PATCH 3/9] Update comment --- src/field_set.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/field_set.ts b/src/field_set.ts index 45265b6e..a00dba7e 100644 --- a/src/field_set.ts +++ b/src/field_set.ts @@ -32,7 +32,7 @@ import { SyncSource } from './sync_source'; // Phone: string // Rating: number // Rich text: string -// Rollup: FieldValue (string[], number[], string) +// Rollup: ReadonlyArray | string | number // Single line text: string // Single select: string // Sync source: SyncSource From aafcfb9bbce2bd5753ce2e1dbaed26dee77a6ff9 Mon Sep 17 00:00:00 2001 From: Stephen Heindel Date: Fri, 20 Oct 2023 16:07:33 -0400 Subject: [PATCH 4/9] Added tentative AI Text typedefs --- src/ai_text.ts | 12 ++++++++++++ src/field_set.ts | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/ai_text.ts diff --git a/src/ai_text.ts b/src/ai_text.ts new file mode 100644 index 00000000..16c749d2 --- /dev/null +++ b/src/ai_text.ts @@ -0,0 +1,12 @@ +export interface AiTextResult { + state: "empty" | "loading" | "generated"; + isState: boolean; + value?: string; +} + +export interface AiTextError { + state: "error"; + errorType: string; + isState: boolean; + value?: string; +} diff --git a/src/field_set.ts b/src/field_set.ts index a00dba7e..77dd8a59 100644 --- a/src/field_set.ts +++ b/src/field_set.ts @@ -3,6 +3,7 @@ import {Attachment} from './attachment'; import {Barcode} from './barcode'; import {Button} from './button'; import { SyncSource } from './sync_source'; +import { AiTextError, AiTextResult } from './ai_text'; // AI Text // Attachment: Attachment @@ -37,7 +38,7 @@ import { SyncSource } from './sync_source'; // Single select: string // Sync source: SyncSource // Url: string -export type FieldValue = string | number | boolean | Collaborator | SyncSource | ReadonlyArray | ReadonlyArray; +export type FieldValue = string | number | boolean | Collaborator | AiTextResult | AiTextError | SyncSource | ReadonlyArray | ReadonlyArray; export interface FieldSet { [key: string]: FieldValue; } From 234e5cc43d5637d2adfcd01dd205d18415991127 Mon Sep 17 00:00:00 2001 From: Stephen Heindel Date: Fri, 20 Oct 2023 16:10:40 -0400 Subject: [PATCH 5/9] Clean up per linting, add more comments --- src/ai_text.ts | 4 ++-- src/field_set.ts | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/ai_text.ts b/src/ai_text.ts index 16c749d2..f0b86b6f 100644 --- a/src/ai_text.ts +++ b/src/ai_text.ts @@ -1,11 +1,11 @@ export interface AiTextResult { - state: "empty" | "loading" | "generated"; + state: 'empty' | 'loading' | 'generated'; isState: boolean; value?: string; } export interface AiTextError { - state: "error"; + state: 'error'; errorType: string; isState: boolean; value?: string; diff --git a/src/field_set.ts b/src/field_set.ts index 77dd8a59..2345709f 100644 --- a/src/field_set.ts +++ b/src/field_set.ts @@ -2,10 +2,11 @@ import {Collaborator} from './collaborator'; import {Attachment} from './attachment'; import {Barcode} from './barcode'; import {Button} from './button'; -import { SyncSource } from './sync_source'; -import { AiTextError, AiTextResult } from './ai_text'; +import {SyncSource} from './sync_source'; +import {AiTextError, AiTextResult} from './ai_text'; -// AI Text +// Built from https://airtable.com/developers/web/api/field-model +// AI Text: AiTextError | AiTextResult // Attachment: Attachment // Auto number: number // Barcode: Barcode @@ -38,7 +39,18 @@ import { AiTextError, AiTextResult } from './ai_text'; // Single select: string // Sync source: SyncSource // Url: string -export type FieldValue = string | number | boolean | Collaborator | AiTextResult | AiTextError | SyncSource | ReadonlyArray | ReadonlyArray; +export type FieldValue = + string | + number | + boolean | + AiTextResult | + AiTextError | + Barcode | + Button | + Collaborator | + SyncSource | + ReadonlyArray | + ReadonlyArray; export interface FieldSet { [key: string]: FieldValue; } From 3ddfbe3139e83f7f71457656854282dd16915148 Mon Sep 17 00:00:00 2001 From: Stephen Heindel Date: Fri, 20 Oct 2023 16:13:52 -0400 Subject: [PATCH 6/9] Restore undefined value --- src/field_set.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/field_set.ts b/src/field_set.ts index 2345709f..c817cd5a 100644 --- a/src/field_set.ts +++ b/src/field_set.ts @@ -40,6 +40,7 @@ import {AiTextError, AiTextResult} from './ai_text'; // Sync source: SyncSource // Url: string export type FieldValue = + undefined | string | number | boolean | From fcb36793b19788de2b16fdb85dedb439fd7aed97 Mon Sep 17 00:00:00 2001 From: Stephen Heindel Date: Fri, 20 Oct 2023 16:20:28 -0400 Subject: [PATCH 7/9] Inspired by pyairtable to make AI one interface --- src/ai_text.ts | 12 +++--------- src/field_set.ts | 5 ++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/ai_text.ts b/src/ai_text.ts index f0b86b6f..55d72afd 100644 --- a/src/ai_text.ts +++ b/src/ai_text.ts @@ -1,12 +1,6 @@ export interface AiTextResult { - state: 'empty' | 'loading' | 'generated'; - isState: boolean; - value?: string; -} - -export interface AiTextError { - state: 'error'; - errorType: string; - isState: boolean; + state: 'empty' | 'loading' | 'generated' | 'error'; + isStale: boolean; value?: string; + errorType?: string; } diff --git a/src/field_set.ts b/src/field_set.ts index c817cd5a..a51ed4fb 100644 --- a/src/field_set.ts +++ b/src/field_set.ts @@ -3,10 +3,10 @@ import {Attachment} from './attachment'; import {Barcode} from './barcode'; import {Button} from './button'; import {SyncSource} from './sync_source'; -import {AiTextError, AiTextResult} from './ai_text'; +import {AiTextResult} from './ai_text'; // Built from https://airtable.com/developers/web/api/field-model -// AI Text: AiTextError | AiTextResult +// AI Text: AiTextResult // Attachment: Attachment // Auto number: number // Barcode: Barcode @@ -45,7 +45,6 @@ export type FieldValue = number | boolean | AiTextResult | - AiTextError | Barcode | Button | Collaborator | From 2e4543cceab69e8608e2c4f4e3af304770fbfb6b Mon Sep 17 00:00:00 2001 From: Stephen Heindel Date: Thu, 1 Aug 2024 11:27:43 -0400 Subject: [PATCH 8/9] Update to 0.12.3 because current version is 0.12.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 24724a1e..d9d7d8ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "airtable", - "version": "0.12.2", + "version": "0.12.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "airtable", - "version": "0.12.2", + "version": "0.12.3", "license": "MIT", "dependencies": { "@types/node": ">=8.0.0 <15", diff --git a/package.json b/package.json index e28fd761..6117cb4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "airtable", - "version": "0.12.2", + "version": "0.12.3", "license": "MIT", "homepage": "https://github.com/airtable/airtable.js", "repository": "git://github.com/airtable/airtable.js.git", From 06d1fd19071d4ba594b66bf94a9c104283e3441b Mon Sep 17 00:00:00 2001 From: Stephen Heindel Date: Thu, 1 Aug 2024 11:29:05 -0400 Subject: [PATCH 9/9] Run tests, build --- build/airtable.browser.js | 2 +- test/test_files/airtable.browser.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/airtable.browser.js b/build/airtable.browser.js index a21733b9..a126e3bc 100644 --- a/build/airtable.browser.js +++ b/build/airtable.browser.js @@ -445,7 +445,7 @@ module.exports = objectToQueryParamString; },{"lodash/isArray":79,"lodash/isNil":85,"lodash/keys":93}],12:[function(require,module,exports){ "use strict"; -module.exports = "0.12.2"; +module.exports = "0.12.3"; },{}],13:[function(require,module,exports){ "use strict"; diff --git a/test/test_files/airtable.browser.js b/test/test_files/airtable.browser.js index a21733b9..a126e3bc 100644 --- a/test/test_files/airtable.browser.js +++ b/test/test_files/airtable.browser.js @@ -445,7 +445,7 @@ module.exports = objectToQueryParamString; },{"lodash/isArray":79,"lodash/isNil":85,"lodash/keys":93}],12:[function(require,module,exports){ "use strict"; -module.exports = "0.12.2"; +module.exports = "0.12.3"; },{}],13:[function(require,module,exports){ "use strict";