@plasmicpkgs/airtable 0.0.249 → 0.0.250

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.
@@ -1,4 +1,4 @@
1
- import registerComponent, { CanvasComponentProps, ComponentMeta } from "@plasmicapp/host/registerComponent";
1
+ import registerComponent, { CanvasComponentProps, CodeComponentMeta } from "@plasmicapp/host/registerComponent";
2
2
  import registerGlobalContext, { GlobalContextMeta } from "@plasmicapp/host/registerGlobalContext";
3
3
  import React from "react";
4
4
  export interface DataSourceInfo {
@@ -42,18 +42,18 @@ interface AirtableCredentialsProviderProps {
42
42
  host?: string;
43
43
  }
44
44
  export declare function AirtableCredentialsProvider({ dataSource, host: maybeHost, children, }: React.PropsWithChildren<AirtableCredentialsProviderProps>): React.JSX.Element;
45
- export declare const airtableRecordMeta: ComponentMeta<AirtableRecordProps>;
45
+ export declare const airtableRecordMeta: CodeComponentMeta<AirtableRecordProps>;
46
46
  export declare function registerAirtableRecord(loader?: {
47
47
  registerComponent: typeof registerComponent;
48
- }, customAirtableRecordMeta?: ComponentMeta<AirtableRecordProps>): void;
49
- export declare const airtableRecordFieldMeta: ComponentMeta<AirtableRecordFieldProps>;
48
+ }, customAirtableRecordMeta?: CodeComponentMeta<AirtableRecordProps>): void;
49
+ export declare const airtableRecordFieldMeta: CodeComponentMeta<AirtableRecordFieldProps>;
50
50
  export declare function registerAirtableRecordField(loader?: {
51
51
  registerComponent: typeof registerComponent;
52
- }, customAirtableRecordFieldMeta?: ComponentMeta<AirtableRecordFieldProps>): void;
53
- export declare const airtableCollectionMeta: ComponentMeta<AirtableCollectionProps>;
52
+ }, customAirtableRecordFieldMeta?: CodeComponentMeta<AirtableRecordFieldProps>): void;
53
+ export declare const airtableCollectionMeta: CodeComponentMeta<AirtableCollectionProps>;
54
54
  export declare function registerAirtableCollection(loader?: {
55
55
  registerComponent: typeof registerComponent;
56
- }, customAirtableCollectionMeta?: ComponentMeta<AirtableCollectionProps>): void;
56
+ }, customAirtableCollectionMeta?: CodeComponentMeta<AirtableCollectionProps>): void;
57
57
  export declare const airtableCredentialsProviderMeta: GlobalContextMeta<AirtableCredentialsProviderProps>;
58
58
  export declare function registerAirtableCredentialsProvider(loader?: {
59
59
  registerGlobalContext: typeof registerGlobalContext;
@@ -1 +1 @@
1
- {"version":3,"file":"airtable.cjs.development.js","sources":["../src/RecordData.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n repeatedElement,\n usePlasmicCanvasContext,\n useSelector,\n} from \"@plasmicapp/host\";\nimport registerComponent, {\n CanvasComponentProps,\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport React from \"react\";\n\nconst defaultHost = \"https://studio.plasmic.app\";\n\nexport interface DataSourceInfo {\n id: string;\n base: string;\n host?: string;\n}\n\nconst CredentialsContext = React.createContext<DataSourceInfo | undefined>(\n undefined\n);\n\ninterface RecordData {\n [field: string]: string | { id: string; url: string; filename: string }[];\n}\n\nexport interface AirtableRecordProps {\n table: string;\n record: string;\n}\n\nexport function AirtableRecord({\n table,\n record,\n children,\n}: React.PropsWithChildren<AirtableRecordProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const data = usePlasmicQueryData(\n JSON.stringify([\"AirtableRecord\", host, base, table, record, dataSourceId]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableRecord is missing the table name\");\n }\n if (!record) {\n throw new Error(\"AirtableRecord is missing the record ID\");\n }\n const pathname = `/${base}/${table}/${record}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json())\n .fields as RecordData;\n }\n );\n\n if (\"error\" in data) {\n return <p>Error: {data.error?.message}</p>;\n }\n\n if (!(\"data\" in data)) {\n return <p>Loading...</p>;\n }\n\n return (\n <DataProvider name={contextKey} data={data.data}>\n {children}\n </DataProvider>\n );\n}\n\nconst contextKey = \"__airtableRecord\";\n\nfunction useRecord() {\n return useSelector(contextKey) as RecordData | undefined;\n}\n\nexport interface AirtableRecordFieldProps\n extends CanvasComponentProps<RecordData | undefined> {\n className?: string;\n style?: React.CSSProperties;\n field?: string;\n}\n\nexport function AirtableRecordField({\n className,\n field,\n style,\n setControlContextData,\n}: AirtableRecordFieldProps) {\n const record = useRecord();\n setControlContextData?.(record);\n\n return (\n <div className={className} style={style}>\n {record\n ? (() => {\n const val = record[field || Object.keys(record)[0]];\n if (val && typeof val === \"object\") {\n return \"Attachment \" + val[0].filename;\n }\n return val;\n })()\n : \"Error: Must provide a record to AirtableRecordField\"}\n </div>\n );\n}\n\nexport interface AirtableCollectionProps {\n table: string;\n fields?: string[];\n filterByFormula?: string;\n maxRecords?: number;\n pageSize?: number;\n sort?: {\n field: string;\n direction?: \"asc\" | \"desc\";\n }[];\n view?: string;\n}\n\nexport function AirtableCollection({\n table,\n children,\n ...props\n}: React.PropsWithChildren<AirtableCollectionProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const searchArray: string[] = [];\n if (props.fields) {\n props.fields.forEach((f) =>\n searchArray.push(\n `${encodeURIComponent(`fields[]`)}=${encodeURIComponent(`${f}`)}`\n )\n );\n }\n ([\"filterByFormula\", \"maxRecords\", \"pageSize\", \"view\"] as const).forEach(\n (prop) => {\n if (props[prop]) {\n searchArray.push(\n `${encodeURIComponent(`${prop}`)}=${encodeURIComponent(\n `${props[prop]}`\n )}`\n );\n }\n }\n );\n if (props.sort) {\n props.sort.forEach((v, i) => {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][field]`)}=${encodeURIComponent(\n `${v.field}`\n )}`\n );\n if (v.direction) {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][direction]`)}=${encodeURIComponent(\n `${v.direction}`\n )}`\n );\n }\n });\n }\n\n const search = searchArray.length === 0 ? \"\" : \"?\" + searchArray.join(\"&\");\n\n const { data, error, isLoading } = usePlasmicQueryData(\n JSON.stringify([\n \"AirtableCollection\",\n host,\n base,\n table,\n search,\n dataSourceId,\n ]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableCollection is missing the table name\");\n }\n const pathname = `/${base}/${table}${search}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json()).records as {\n fields: RecordData;\n id: string;\n }[];\n }\n );\n\n if (error) {\n return <p>Error: {error.message}</p>;\n }\n\n if (isLoading) {\n return <p>Loading...</p>;\n }\n\n return (\n <>\n {(data ?? []).map((record, index) => (\n <DataProvider key={record.id} name={contextKey} data={record.fields}>\n {repeatedElement(index, children)}\n </DataProvider>\n ))}\n </>\n );\n}\n\ninterface AirtableCredentialsProviderProps {\n dataSource: DataSourceInfo;\n host?: string;\n}\n\nexport function AirtableCredentialsProvider({\n dataSource,\n host: maybeHost,\n children,\n}: React.PropsWithChildren<AirtableCredentialsProviderProps>) {\n const inCanvas = usePlasmicCanvasContext();\n if (inCanvas && (!dataSource || !dataSource.id || !dataSource.base)) {\n return (\n <p>\n Error: Missing Data Source. Please select a Data Source from the\n Airtable Credentials Provider\n </p>\n );\n }\n const host = maybeHost || defaultHost;\n return (\n <CredentialsContext.Provider value={{ ...dataSource, host }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\nconst thisModule = \"@plasmicpkgs/airtable\";\n\nexport const airtableRecordMeta: ComponentMeta<AirtableRecordProps> = {\n name: \"hostless-airtable-record\",\n displayName: \"Airtable Record\",\n importPath: thisModule,\n importName: \"AirtableRecord\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n record: {\n type: \"string\",\n displayName: \"Record\",\n description: \"The table record ID\",\n },\n },\n};\n\nexport function registerAirtableRecord(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordMeta?: ComponentMeta<AirtableRecordProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n } else {\n registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n }\n}\n\nexport const airtableRecordFieldMeta: ComponentMeta<AirtableRecordFieldProps> = {\n name: \"hostless-airtable-record-field\",\n displayName: \"Airtable Record Field\",\n importPath: thisModule,\n importName: \"AirtableRecordField\",\n props: {\n field: {\n type: \"choice\",\n displayName: \"Field Name\",\n defaultValueHint: \"The first field\",\n options: (_props, data) => {\n return data ? Object.keys(data) : [\"Data unavailable\"];\n },\n },\n },\n};\n\nexport function registerAirtableRecordField(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordFieldMeta?: ComponentMeta<AirtableRecordFieldProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n } else {\n registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n }\n}\n\nexport const airtableCollectionMeta: ComponentMeta<AirtableCollectionProps> = {\n name: \"hostless-airtable-collection\",\n displayName: \"Airtable Collection\",\n importPath: thisModule,\n importName: \"AirtableCollection\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n isRepeated: true,\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n fields: {\n type: \"object\",\n displayName: \"Fields\",\n description: \"List of strings containing the fields to be included\",\n },\n maxRecords: {\n type: \"number\",\n displayName: \"Max Records\",\n description: \"The maximum total number of records that will be returned\",\n defaultValueHint: 100,\n max: 100,\n min: 1,\n },\n view: {\n type: \"string\",\n displayName: \"View\",\n description:\n \"The name or ID of a view in the table. If set, only records from that view will be returned\",\n },\n sort: {\n type: \"object\",\n displayName: \"Sort\",\n description:\n 'A list of Airtable sort objects that specifies how the records will be ordered. Each sort object must have a field key specifying the name of the field to sort on, and an optional direction key that is either \"asc\" or \"desc\". The default direction is \"asc\"',\n },\n filterByFormula: {\n type: \"string\",\n displayName: \"Filter by Formula\",\n description: \"An Airtable formula used to filter records\",\n },\n },\n};\n\nexport function registerAirtableCollection(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableCollectionMeta?: ComponentMeta<AirtableCollectionProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n } else {\n registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n }\n}\n\nexport const airtableCredentialsProviderMeta: GlobalContextMeta<AirtableCredentialsProviderProps> = {\n name: \"hostless-airtable-credentials-provider\",\n displayName: \"Airtable Credentials Provider\",\n importPath: thisModule,\n importName: \"AirtableCredentialsProvider\",\n props: {\n dataSource: {\n type: \"dataSource\",\n dataSource: \"airtable\",\n displayName: \"Data Source\",\n description: \"The Airtable Data Source to use\",\n },\n host: {\n type: \"string\",\n displayName: \"Host\",\n description: \"Plasmic Server-Data URL\",\n defaultValueHint: defaultHost,\n },\n },\n};\n\nexport function registerAirtableCredentialsProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customAirtableCredentialsProviderMeta?: GlobalContextMeta<AirtableCredentialsProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n } else {\n registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n }\n}\n","export * from \"./RecordData\";\nimport {\n registerAirtableCollection,\n registerAirtableCredentialsProvider,\n registerAirtableRecord,\n registerAirtableRecordField,\n} from \"./RecordData\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n registerAirtableCollection(loader);\n registerAirtableCredentialsProvider(loader);\n registerAirtableRecord(loader);\n registerAirtableRecordField(loader);\n}\n"],"names":["defaultHost","CredentialsContext","React","createContext","undefined","AirtableRecord","_ref","table","record","children","credentialsContext","useContext","dataSourceId","id","base","host","data","usePlasmicQueryData","JSON","stringify","_asyncToGenerator","_regeneratorRuntime","mark","_callee","pathname","url","wrap","_callee$","_context","prev","next","Error","encodeURIComponent","fetch","method","sent","json","abrupt","fields","stop","_data$error","error","message","DataProvider","name","contextKey","useRecord","useSelector","AirtableRecordField","_ref3","className","field","style","setControlContextData","val","Object","keys","filename","AirtableCollection","_ref4","props","_objectWithoutPropertiesLoose","_excluded","searchArray","forEach","f","push","prop","sort","v","i","direction","search","length","join","_usePlasmicQueryData","_callee2","_callee2$","_context2","records","isLoading","map","index","key","repeatedElement","AirtableCredentialsProvider","_ref6","dataSource","maybeHost","inCanvas","usePlasmicCanvasContext","Provider","value","_extends","thisModule","airtableRecordMeta","displayName","importPath","importName","providesData","type","defaultValue","description","registerAirtableRecord","loader","customAirtableRecordMeta","registerComponent","airtableRecordFieldMeta","defaultValueHint","options","_props","registerAirtableRecordField","customAirtableRecordFieldMeta","airtableCollectionMeta","isRepeated","maxRecords","max","min","view","filterByFormula","registerAirtableCollection","customAirtableCollectionMeta","airtableCredentialsProviderMeta","registerAirtableCredentialsProvider","customAirtableCredentialsProviderMeta","registerGlobalContext","registerAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAMA,WAAW,GAAG,4BAA4B;AAQhD,IAAMC,kBAAkB,gBAAGC,KAAK,CAACC,aAAa,CAC5CC,SAAS,CACV;SAWeC,cAAcA,CAAAC,IAAA;MAC5BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;EAER,IAAMC,kBAAkB,GAAGR,KAAK,CAACS,UAAU,CAACV,kBAAkB,CAAC;EAE/D,IAAMW,YAAY,GAAGF,kBAAkB,IAAIA,kBAAkB,CAACG,EAAE;EAChE,IAAMC,IAAI,GAAGJ,kBAAkB,IAAIA,kBAAkB,CAACI,IAAI;EAC1D,IAAMC,MAAI,GAAIL,kBAAkB,IAAIA,kBAAkB,CAACK,IAAI,IAAKf,WAAW;EAE3E,IAAMgB,IAAI,GAAGC,yBAAmB,CAC9BC,IAAI,CAACC,SAAS,CAAC,CAAC,gBAAgB,EAAEJ,MAAI,EAAED,IAAI,EAAEP,KAAK,EAAEC,MAA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A6B;EACzCtC,KAAK,EAAE;IACL2B,UAAU,EAAE;MACVa,IAAI,EAAE,YAAY;MAClBb,UAAU,EAAE,UAAU;MACtBS,WAAW,EAAE,aAAa;MAC1BM,WAAW,EAAE;KACd;IACDvF,IAAI,EAAE;MACJqF,IAAI,EAAE,QAAQ;MACdJ,WAAW,EAAE,MAAM;MACnBM,WAAW,EAAE,yBAAyB;MACtCM,gBAAgB,EAAE5G;;;;SAKR2H,mCAAmCA,CACjDnB,MAAgE,EAChEoB,qCAA2F;EAE3F,IAAIpB,MAAM,EAAE;IACVA,MAAM,CAACqB,qBAAqB,CAC1BxC,2BAA2B,EAC3BuC,qCAAqC,WAArCA,qCAAqC,GAAIF,+BAA+B,CACzE;GACF,MAAM;IACLG,qBAAqB,CACnBxC,2BAA2B,EAC3BuC,qCAAqC,WAArCA,qCAAqC,GAAIF,+BAA+B,CACzE;;AAEL;;SCpbgBI,WAAWA,CAACtB,MAG3B;EACCgB,0BAA0B,CAAChB,MAAM,CAAC;EAClCmB,mCAAmC,CAACnB,MAAM,CAAC;EAC3CD,sBAAsB,CAACC,MAAM,CAAC;EAC9BO,2BAA2B,CAACP,MAAM,CAAC;AACrC;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"airtable.cjs.development.js","sources":["../src/RecordData.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n repeatedElement,\n usePlasmicCanvasContext,\n useSelector,\n} from \"@plasmicapp/host\";\nimport registerComponent, {\n CanvasComponentProps,\n CodeComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport React from \"react\";\n\nconst defaultHost = \"https://studio.plasmic.app\";\n\nexport interface DataSourceInfo {\n id: string;\n base: string;\n host?: string;\n}\n\nconst CredentialsContext = React.createContext<DataSourceInfo | undefined>(\n undefined\n);\n\ninterface RecordData {\n [field: string]: string | { id: string; url: string; filename: string }[];\n}\n\nexport interface AirtableRecordProps {\n table: string;\n record: string;\n}\n\nexport function AirtableRecord({\n table,\n record,\n children,\n}: React.PropsWithChildren<AirtableRecordProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const data = usePlasmicQueryData(\n JSON.stringify([\"AirtableRecord\", host, base, table, record, dataSourceId]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableRecord is missing the table name\");\n }\n if (!record) {\n throw new Error(\"AirtableRecord is missing the record ID\");\n }\n const pathname = `/${base}/${table}/${record}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json())\n .fields as RecordData;\n }\n );\n\n if (\"error\" in data) {\n return <p>Error: {data.error?.message}</p>;\n }\n\n if (!(\"data\" in data)) {\n return <p>Loading...</p>;\n }\n\n return (\n <DataProvider name={contextKey} data={data.data}>\n {children}\n </DataProvider>\n );\n}\n\nconst contextKey = \"__airtableRecord\";\n\nfunction useRecord() {\n return useSelector(contextKey) as RecordData | undefined;\n}\n\nexport interface AirtableRecordFieldProps\n extends CanvasComponentProps<RecordData | undefined> {\n className?: string;\n style?: React.CSSProperties;\n field?: string;\n}\n\nexport function AirtableRecordField({\n className,\n field,\n style,\n setControlContextData,\n}: AirtableRecordFieldProps) {\n const record = useRecord();\n setControlContextData?.(record);\n\n return (\n <div className={className} style={style}>\n {record\n ? (() => {\n const val = record[field || Object.keys(record)[0]];\n if (val && typeof val === \"object\") {\n return \"Attachment \" + val[0].filename;\n }\n return val;\n })()\n : \"Error: Must provide a record to AirtableRecordField\"}\n </div>\n );\n}\n\nexport interface AirtableCollectionProps {\n table: string;\n fields?: string[];\n filterByFormula?: string;\n maxRecords?: number;\n pageSize?: number;\n sort?: {\n field: string;\n direction?: \"asc\" | \"desc\";\n }[];\n view?: string;\n}\n\nexport function AirtableCollection({\n table,\n children,\n ...props\n}: React.PropsWithChildren<AirtableCollectionProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const searchArray: string[] = [];\n if (props.fields) {\n props.fields.forEach((f) =>\n searchArray.push(\n `${encodeURIComponent(`fields[]`)}=${encodeURIComponent(`${f}`)}`\n )\n );\n }\n ([\"filterByFormula\", \"maxRecords\", \"pageSize\", \"view\"] as const).forEach(\n (prop) => {\n if (props[prop]) {\n searchArray.push(\n `${encodeURIComponent(`${prop}`)}=${encodeURIComponent(\n `${props[prop]}`\n )}`\n );\n }\n }\n );\n if (props.sort) {\n props.sort.forEach((v, i) => {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][field]`)}=${encodeURIComponent(\n `${v.field}`\n )}`\n );\n if (v.direction) {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][direction]`)}=${encodeURIComponent(\n `${v.direction}`\n )}`\n );\n }\n });\n }\n\n const search = searchArray.length === 0 ? \"\" : \"?\" + searchArray.join(\"&\");\n\n const { data, error, isLoading } = usePlasmicQueryData(\n JSON.stringify([\n \"AirtableCollection\",\n host,\n base,\n table,\n search,\n dataSourceId,\n ]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableCollection is missing the table name\");\n }\n const pathname = `/${base}/${table}${search}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json()).records as {\n fields: RecordData;\n id: string;\n }[];\n }\n );\n\n if (error) {\n return <p>Error: {error.message}</p>;\n }\n\n if (isLoading) {\n return <p>Loading...</p>;\n }\n\n return (\n <>\n {(data ?? []).map((record, index) => (\n <DataProvider key={record.id} name={contextKey} data={record.fields}>\n {repeatedElement(index, children)}\n </DataProvider>\n ))}\n </>\n );\n}\n\ninterface AirtableCredentialsProviderProps {\n dataSource: DataSourceInfo;\n host?: string;\n}\n\nexport function AirtableCredentialsProvider({\n dataSource,\n host: maybeHost,\n children,\n}: React.PropsWithChildren<AirtableCredentialsProviderProps>) {\n const inCanvas = usePlasmicCanvasContext();\n if (inCanvas && (!dataSource || !dataSource.id || !dataSource.base)) {\n return (\n <p>\n Error: Missing Data Source. Please select a Data Source from the\n Airtable Credentials Provider\n </p>\n );\n }\n const host = maybeHost || defaultHost;\n return (\n <CredentialsContext.Provider value={{ ...dataSource, host }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\nconst thisModule = \"@plasmicpkgs/airtable\";\n\nexport const airtableRecordMeta: CodeComponentMeta<AirtableRecordProps> = {\n name: \"hostless-airtable-record\",\n displayName: \"Airtable Record\",\n importPath: thisModule,\n importName: \"AirtableRecord\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n record: {\n type: \"string\",\n displayName: \"Record\",\n description: \"The table record ID\",\n },\n },\n};\n\nexport function registerAirtableRecord(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordMeta?: CodeComponentMeta<AirtableRecordProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n } else {\n registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n }\n}\n\nexport const airtableRecordFieldMeta: CodeComponentMeta<AirtableRecordFieldProps> =\n {\n name: \"hostless-airtable-record-field\",\n displayName: \"Airtable Record Field\",\n importPath: thisModule,\n importName: \"AirtableRecordField\",\n props: {\n field: {\n type: \"choice\",\n displayName: \"Field Name\",\n defaultValueHint: \"The first field\",\n options: (_props, data) => {\n return data ? Object.keys(data) : [\"Data unavailable\"];\n },\n },\n },\n };\n\nexport function registerAirtableRecordField(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordFieldMeta?: CodeComponentMeta<AirtableRecordFieldProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n } else {\n registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n }\n}\n\nexport const airtableCollectionMeta: CodeComponentMeta<AirtableCollectionProps> =\n {\n name: \"hostless-airtable-collection\",\n displayName: \"Airtable Collection\",\n importPath: thisModule,\n importName: \"AirtableCollection\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n isRepeated: true,\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n fields: {\n type: \"object\",\n displayName: \"Fields\",\n description: \"List of strings containing the fields to be included\",\n },\n maxRecords: {\n type: \"number\",\n displayName: \"Max Records\",\n description:\n \"The maximum total number of records that will be returned\",\n defaultValueHint: 100,\n max: 100,\n min: 1,\n },\n view: {\n type: \"string\",\n displayName: \"View\",\n description:\n \"The name or ID of a view in the table. If set, only records from that view will be returned\",\n },\n sort: {\n type: \"object\",\n displayName: \"Sort\",\n description:\n 'A list of Airtable sort objects that specifies how the records will be ordered. Each sort object must have a field key specifying the name of the field to sort on, and an optional direction key that is either \"asc\" or \"desc\". The default direction is \"asc\"',\n },\n filterByFormula: {\n type: \"string\",\n displayName: \"Filter by Formula\",\n description: \"An Airtable formula used to filter records\",\n },\n },\n };\n\nexport function registerAirtableCollection(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableCollectionMeta?: CodeComponentMeta<AirtableCollectionProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n } else {\n registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n }\n}\n\nexport const airtableCredentialsProviderMeta: GlobalContextMeta<AirtableCredentialsProviderProps> =\n {\n name: \"hostless-airtable-credentials-provider\",\n displayName: \"Airtable Credentials Provider\",\n importPath: thisModule,\n importName: \"AirtableCredentialsProvider\",\n props: {\n dataSource: {\n type: \"dataSource\",\n dataSource: \"airtable\",\n displayName: \"Data Source\",\n description: \"The Airtable Data Source to use\",\n },\n host: {\n type: \"string\",\n displayName: \"Host\",\n description: \"Plasmic Server-Data URL\",\n defaultValueHint: defaultHost,\n },\n },\n };\n\nexport function registerAirtableCredentialsProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customAirtableCredentialsProviderMeta?: GlobalContextMeta<AirtableCredentialsProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n } else {\n registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n }\n}\n","export * from \"./RecordData\";\nimport {\n registerAirtableCollection,\n registerAirtableCredentialsProvider,\n registerAirtableRecord,\n registerAirtableRecordField,\n} from \"./RecordData\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n registerAirtableCollection(loader);\n registerAirtableCredentialsProvider(loader);\n registerAirtableRecord(loader);\n registerAirtableRecordField(loader);\n}\n"],"names":["defaultHost","CredentialsContext","React","createContext","undefined","AirtableRecord","_ref","table","record","children","credentialsContext","useContext","dataSourceId","id","base","host","data","usePlasmicQueryData","JSON","stringify","_asyncToGenerator","_regeneratorRuntime","mark","_callee","pathname","url","wrap","_callee$","_context","prev","next","Error","encodeURIComponent","fetch","method","sent","json","abrupt","fields","stop","_data$error","error","message","DataProvider","name","contextKey","useRecord","useSelector","AirtableRecordField","_ref3","className","field","style","setControlContextData","val","Object","keys","filename","AirtableCollection","_ref4","props","_objectWithoutPropertiesLoose","_excluded","searchArray","forEach","f","push","prop","sort","v","i","direction","search","length","join","_usePlasmicQueryData","_callee2","_callee2$","_context2","records","isLoading","map","index","key","repeatedElement","AirtableCredentialsProvider","_ref6","dataSource","maybeHost","inCanvas","usePlasmicCanvasContext","Provider","value","_extends","thisModule","airtableRecordMeta","displayName","importPath","importName","providesData","type","defaultValue","description","registerAirtableRecord","loader","customAirtableRecordMeta","registerComponent","airtableRecordFieldMeta","defaultValueHint","options","_props","registerAirtableRecordField","customAirtableRecordFieldMeta","airtableCollectionMeta","isRepeated","maxRecords","max","min","view","filterByFormula","registerAirtableCollection","customAirtableCollectionMeta","airtableCredentialsProviderMeta","registerAirtableCredentialsProvider","customAirtableCredentialsProviderMeta","registerGlobalContext","registerAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAMA,WAAW,GAAG,4BAA4B;AAQhD,IAAMC,kBAAkB,gBAAGC,KAA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;EAC3CD,sBAAsB,CAACC,MAAM,CAAC;EAC9BO,2BAA2B,CAACP,MAAM,CAAC;AACrC;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"airtable.cjs.production.min.js","sources":["../src/RecordData.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n repeatedElement,\n usePlasmicCanvasContext,\n useSelector,\n} from \"@plasmicapp/host\";\nimport registerComponent, {\n CanvasComponentProps,\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport React from \"react\";\n\nconst defaultHost = \"https://studio.plasmic.app\";\n\nexport interface DataSourceInfo {\n id: string;\n base: string;\n host?: string;\n}\n\nconst CredentialsContext = React.createContext<DataSourceInfo | undefined>(\n undefined\n);\n\ninterface RecordData {\n [field: string]: string | { id: string; url: string; filename: string }[];\n}\n\nexport interface AirtableRecordProps {\n table: string;\n record: string;\n}\n\nexport function AirtableRecord({\n table,\n record,\n children,\n}: React.PropsWithChildren<AirtableRecordProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const data = usePlasmicQueryData(\n JSON.stringify([\"AirtableRecord\", host, base, table, record, dataSourceId]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableRecord is missing the table name\");\n }\n if (!record) {\n throw new Error(\"AirtableRecord is missing the record ID\");\n }\n const pathname = `/${base}/${table}/${record}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json())\n .fields as RecordData;\n }\n );\n\n if (\"error\" in data) {\n return <p>Error: {data.error?.message}</p>;\n }\n\n if (!(\"data\" in data)) {\n return <p>Loading...</p>;\n }\n\n return (\n <DataProvider name={contextKey} data={data.data}>\n {children}\n </DataProvider>\n );\n}\n\nconst contextKey = \"__airtableRecord\";\n\nfunction useRecord() {\n return useSelector(contextKey) as RecordData | undefined;\n}\n\nexport interface AirtableRecordFieldProps\n extends CanvasComponentProps<RecordData | undefined> {\n className?: string;\n style?: React.CSSProperties;\n field?: string;\n}\n\nexport function AirtableRecordField({\n className,\n field,\n style,\n setControlContextData,\n}: AirtableRecordFieldProps) {\n const record = useRecord();\n setControlContextData?.(record);\n\n return (\n <div className={className} style={style}>\n {record\n ? (() => {\n const val = record[field || Object.keys(record)[0]];\n if (val && typeof val === \"object\") {\n return \"Attachment \" + val[0].filename;\n }\n return val;\n })()\n : \"Error: Must provide a record to AirtableRecordField\"}\n </div>\n );\n}\n\nexport interface AirtableCollectionProps {\n table: string;\n fields?: string[];\n filterByFormula?: string;\n maxRecords?: number;\n pageSize?: number;\n sort?: {\n field: string;\n direction?: \"asc\" | \"desc\";\n }[];\n view?: string;\n}\n\nexport function AirtableCollection({\n table,\n children,\n ...props\n}: React.PropsWithChildren<AirtableCollectionProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const searchArray: string[] = [];\n if (props.fields) {\n props.fields.forEach((f) =>\n searchArray.push(\n `${encodeURIComponent(`fields[]`)}=${encodeURIComponent(`${f}`)}`\n )\n );\n }\n ([\"filterByFormula\", \"maxRecords\", \"pageSize\", \"view\"] as const).forEach(\n (prop) => {\n if (props[prop]) {\n searchArray.push(\n `${encodeURIComponent(`${prop}`)}=${encodeURIComponent(\n `${props[prop]}`\n )}`\n );\n }\n }\n );\n if (props.sort) {\n props.sort.forEach((v, i) => {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][field]`)}=${encodeURIComponent(\n `${v.field}`\n )}`\n );\n if (v.direction) {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][direction]`)}=${encodeURIComponent(\n `${v.direction}`\n )}`\n );\n }\n });\n }\n\n const search = searchArray.length === 0 ? \"\" : \"?\" + searchArray.join(\"&\");\n\n const { data, error, isLoading } = usePlasmicQueryData(\n JSON.stringify([\n \"AirtableCollection\",\n host,\n base,\n table,\n search,\n dataSourceId,\n ]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableCollection is missing the table name\");\n }\n const pathname = `/${base}/${table}${search}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json()).records as {\n fields: RecordData;\n id: string;\n }[];\n }\n );\n\n if (error) {\n return <p>Error: {error.message}</p>;\n }\n\n if (isLoading) {\n return <p>Loading...</p>;\n }\n\n return (\n <>\n {(data ?? []).map((record, index) => (\n <DataProvider key={record.id} name={contextKey} data={record.fields}>\n {repeatedElement(index, children)}\n </DataProvider>\n ))}\n </>\n );\n}\n\ninterface AirtableCredentialsProviderProps {\n dataSource: DataSourceInfo;\n host?: string;\n}\n\nexport function AirtableCredentialsProvider({\n dataSource,\n host: maybeHost,\n children,\n}: React.PropsWithChildren<AirtableCredentialsProviderProps>) {\n const inCanvas = usePlasmicCanvasContext();\n if (inCanvas && (!dataSource || !dataSource.id || !dataSource.base)) {\n return (\n <p>\n Error: Missing Data Source. Please select a Data Source from the\n Airtable Credentials Provider\n </p>\n );\n }\n const host = maybeHost || defaultHost;\n return (\n <CredentialsContext.Provider value={{ ...dataSource, host }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\nconst thisModule = \"@plasmicpkgs/airtable\";\n\nexport const airtableRecordMeta: ComponentMeta<AirtableRecordProps> = {\n name: \"hostless-airtable-record\",\n displayName: \"Airtable Record\",\n importPath: thisModule,\n importName: \"AirtableRecord\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n record: {\n type: \"string\",\n displayName: \"Record\",\n description: \"The table record ID\",\n },\n },\n};\n\nexport function registerAirtableRecord(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordMeta?: ComponentMeta<AirtableRecordProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n } else {\n registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n }\n}\n\nexport const airtableRecordFieldMeta: ComponentMeta<AirtableRecordFieldProps> = {\n name: \"hostless-airtable-record-field\",\n displayName: \"Airtable Record Field\",\n importPath: thisModule,\n importName: \"AirtableRecordField\",\n props: {\n field: {\n type: \"choice\",\n displayName: \"Field Name\",\n defaultValueHint: \"The first field\",\n options: (_props, data) => {\n return data ? Object.keys(data) : [\"Data unavailable\"];\n },\n },\n },\n};\n\nexport function registerAirtableRecordField(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordFieldMeta?: ComponentMeta<AirtableRecordFieldProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n } else {\n registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n }\n}\n\nexport const airtableCollectionMeta: ComponentMeta<AirtableCollectionProps> = {\n name: \"hostless-airtable-collection\",\n displayName: \"Airtable Collection\",\n importPath: thisModule,\n importName: \"AirtableCollection\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n isRepeated: true,\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n fields: {\n type: \"object\",\n displayName: \"Fields\",\n description: \"List of strings containing the fields to be included\",\n },\n maxRecords: {\n type: \"number\",\n displayName: \"Max Records\",\n description: \"The maximum total number of records that will be returned\",\n defaultValueHint: 100,\n max: 100,\n min: 1,\n },\n view: {\n type: \"string\",\n displayName: \"View\",\n description:\n \"The name or ID of a view in the table. If set, only records from that view will be returned\",\n },\n sort: {\n type: \"object\",\n displayName: \"Sort\",\n description:\n 'A list of Airtable sort objects that specifies how the records will be ordered. Each sort object must have a field key specifying the name of the field to sort on, and an optional direction key that is either \"asc\" or \"desc\". The default direction is \"asc\"',\n },\n filterByFormula: {\n type: \"string\",\n displayName: \"Filter by Formula\",\n description: \"An Airtable formula used to filter records\",\n },\n },\n};\n\nexport function registerAirtableCollection(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableCollectionMeta?: ComponentMeta<AirtableCollectionProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n } else {\n registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n }\n}\n\nexport const airtableCredentialsProviderMeta: GlobalContextMeta<AirtableCredentialsProviderProps> = {\n name: \"hostless-airtable-credentials-provider\",\n displayName: \"Airtable Credentials Provider\",\n importPath: thisModule,\n importName: \"AirtableCredentialsProvider\",\n props: {\n dataSource: {\n type: \"dataSource\",\n dataSource: \"airtable\",\n displayName: \"Data Source\",\n description: \"The Airtable Data Source to use\",\n },\n host: {\n type: \"string\",\n displayName: \"Host\",\n description: \"Plasmic Server-Data URL\",\n defaultValueHint: defaultHost,\n },\n },\n};\n\nexport function registerAirtableCredentialsProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customAirtableCredentialsProviderMeta?: GlobalContextMeta<AirtableCredentialsProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n } else {\n registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n }\n}\n","export * from \"./RecordData\";\nimport {\n registerAirtableCollection,\n registerAirtableCredentialsProvider,\n registerAirtableRecord,\n registerAirtableRecordField,\n} from \"./RecordData\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n registerAirtableCollection(loader);\n registerAirtableCredentialsProvider(loader);\n registerAirtableRecord(loader);\n registerAirtableRecordField(loader);\n}\n"],"names":["defaultHost","CredentialsContext","React","createContext","undefined","AirtableRecord","_ref","_data$error","table","record","children","credentialsContext","useContext","dataSourceId","id","base","host","data","usePlasmicQueryData","JSON","stringify","_asyncToGenerator","_regeneratorRuntime","mark","_callee","url","wrap","_context","prev","next","Error","encodeURIComponent","fetch","method","sent","json","abrupt","fields","stop","error","message","DataProvider","name","contextKey","AirtableRecordField","_ref3","val","className","field","style","setControlContextData","useSelector","Object","keys","filename","AirtableCollection","_ref4","props","_objectWithoutPropertiesLoose","_excluded","searchArray","forEach","f","push","prop","sort","v","i","direction","search","length","join","_usePlasmicQueryData","_callee2","_context2","records","isLoading","map","index","key","repeatedElement","AirtableCredentialsProvider","_ref6","dataSource","maybeHost","usePlasmicCanvasContext","Provider","value","_extends","thisModule","airtableRecordMeta","displayName","importPath","importName","providesData","type","defaultValue","description","registerAirtableRecord","loader","customAirtableRecordMeta","registerComponent","airtableRecordFieldMeta","defaultValueHint","options","_props","registerAirtableRecordField","customAirtableRecordFieldMeta","airtableCollectionMeta","isRepeated","maxRecords","max","min","view","filterByFormula","registerAirtableCollection","customAirtableCollectionMeta","airtableCredentialsProviderMeta","registerAirtableCredentialsProvider","customAirtableCredentials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iBAAkBvG,cAKRsH,EACdnB,EACAoB,GAEIpB,EACFA,EAAOqB,sBACLvC,QACAsC,EAAAA,EAAyCF,GAG3CG,EACEvC,QACAsC,EAAAA,EAAyCF,8bCjbnBlB,GAI1BgB,EAA2BhB,GAC3BmB,EAAoCnB,GACpCD,EAAuBC,GACvBO,EAA4BP"}
1
+ {"version":3,"file":"airtable.cjs.production.min.js","sources":["../src/RecordData.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n repeatedElement,\n usePlasmicCanvasContext,\n useSelector,\n} from \"@plasmicapp/host\";\nimport registerComponent, {\n CanvasComponentProps,\n CodeComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport React from \"react\";\n\nconst defaultHost = \"https://studio.plasmic.app\";\n\nexport interface DataSourceInfo {\n id: string;\n base: string;\n host?: string;\n}\n\nconst CredentialsContext = React.createContext<DataSourceInfo | undefined>(\n undefined\n);\n\ninterface RecordData {\n [field: string]: string | { id: string; url: string; filename: string }[];\n}\n\nexport interface AirtableRecordProps {\n table: string;\n record: string;\n}\n\nexport function AirtableRecord({\n table,\n record,\n children,\n}: React.PropsWithChildren<AirtableRecordProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const data = usePlasmicQueryData(\n JSON.stringify([\"AirtableRecord\", host, base, table, record, dataSourceId]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableRecord is missing the table name\");\n }\n if (!record) {\n throw new Error(\"AirtableRecord is missing the record ID\");\n }\n const pathname = `/${base}/${table}/${record}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json())\n .fields as RecordData;\n }\n );\n\n if (\"error\" in data) {\n return <p>Error: {data.error?.message}</p>;\n }\n\n if (!(\"data\" in data)) {\n return <p>Loading...</p>;\n }\n\n return (\n <DataProvider name={contextKey} data={data.data}>\n {children}\n </DataProvider>\n );\n}\n\nconst contextKey = \"__airtableRecord\";\n\nfunction useRecord() {\n return useSelector(contextKey) as RecordData | undefined;\n}\n\nexport interface AirtableRecordFieldProps\n extends CanvasComponentProps<RecordData | undefined> {\n className?: string;\n style?: React.CSSProperties;\n field?: string;\n}\n\nexport function AirtableRecordField({\n className,\n field,\n style,\n setControlContextData,\n}: AirtableRecordFieldProps) {\n const record = useRecord();\n setControlContextData?.(record);\n\n return (\n <div className={className} style={style}>\n {record\n ? (() => {\n const val = record[field || Object.keys(record)[0]];\n if (val && typeof val === \"object\") {\n return \"Attachment \" + val[0].filename;\n }\n return val;\n })()\n : \"Error: Must provide a record to AirtableRecordField\"}\n </div>\n );\n}\n\nexport interface AirtableCollectionProps {\n table: string;\n fields?: string[];\n filterByFormula?: string;\n maxRecords?: number;\n pageSize?: number;\n sort?: {\n field: string;\n direction?: \"asc\" | \"desc\";\n }[];\n view?: string;\n}\n\nexport function AirtableCollection({\n table,\n children,\n ...props\n}: React.PropsWithChildren<AirtableCollectionProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const searchArray: string[] = [];\n if (props.fields) {\n props.fields.forEach((f) =>\n searchArray.push(\n `${encodeURIComponent(`fields[]`)}=${encodeURIComponent(`${f}`)}`\n )\n );\n }\n ([\"filterByFormula\", \"maxRecords\", \"pageSize\", \"view\"] as const).forEach(\n (prop) => {\n if (props[prop]) {\n searchArray.push(\n `${encodeURIComponent(`${prop}`)}=${encodeURIComponent(\n `${props[prop]}`\n )}`\n );\n }\n }\n );\n if (props.sort) {\n props.sort.forEach((v, i) => {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][field]`)}=${encodeURIComponent(\n `${v.field}`\n )}`\n );\n if (v.direction) {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][direction]`)}=${encodeURIComponent(\n `${v.direction}`\n )}`\n );\n }\n });\n }\n\n const search = searchArray.length === 0 ? \"\" : \"?\" + searchArray.join(\"&\");\n\n const { data, error, isLoading } = usePlasmicQueryData(\n JSON.stringify([\n \"AirtableCollection\",\n host,\n base,\n table,\n search,\n dataSourceId,\n ]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableCollection is missing the table name\");\n }\n const pathname = `/${base}/${table}${search}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json()).records as {\n fields: RecordData;\n id: string;\n }[];\n }\n );\n\n if (error) {\n return <p>Error: {error.message}</p>;\n }\n\n if (isLoading) {\n return <p>Loading...</p>;\n }\n\n return (\n <>\n {(data ?? []).map((record, index) => (\n <DataProvider key={record.id} name={contextKey} data={record.fields}>\n {repeatedElement(index, children)}\n </DataProvider>\n ))}\n </>\n );\n}\n\ninterface AirtableCredentialsProviderProps {\n dataSource: DataSourceInfo;\n host?: string;\n}\n\nexport function AirtableCredentialsProvider({\n dataSource,\n host: maybeHost,\n children,\n}: React.PropsWithChildren<AirtableCredentialsProviderProps>) {\n const inCanvas = usePlasmicCanvasContext();\n if (inCanvas && (!dataSource || !dataSource.id || !dataSource.base)) {\n return (\n <p>\n Error: Missing Data Source. Please select a Data Source from the\n Airtable Credentials Provider\n </p>\n );\n }\n const host = maybeHost || defaultHost;\n return (\n <CredentialsContext.Provider value={{ ...dataSource, host }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\nconst thisModule = \"@plasmicpkgs/airtable\";\n\nexport const airtableRecordMeta: CodeComponentMeta<AirtableRecordProps> = {\n name: \"hostless-airtable-record\",\n displayName: \"Airtable Record\",\n importPath: thisModule,\n importName: \"AirtableRecord\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n record: {\n type: \"string\",\n displayName: \"Record\",\n description: \"The table record ID\",\n },\n },\n};\n\nexport function registerAirtableRecord(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordMeta?: CodeComponentMeta<AirtableRecordProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n } else {\n registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n }\n}\n\nexport const airtableRecordFieldMeta: CodeComponentMeta<AirtableRecordFieldProps> =\n {\n name: \"hostless-airtable-record-field\",\n displayName: \"Airtable Record Field\",\n importPath: thisModule,\n importName: \"AirtableRecordField\",\n props: {\n field: {\n type: \"choice\",\n displayName: \"Field Name\",\n defaultValueHint: \"The first field\",\n options: (_props, data) => {\n return data ? Object.keys(data) : [\"Data unavailable\"];\n },\n },\n },\n };\n\nexport function registerAirtableRecordField(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordFieldMeta?: CodeComponentMeta<AirtableRecordFieldProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n } else {\n registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n }\n}\n\nexport const airtableCollectionMeta: CodeComponentMeta<AirtableCollectionProps> =\n {\n name: \"hostless-airtable-collection\",\n displayName: \"Airtable Collection\",\n importPath: thisModule,\n importName: \"AirtableCollection\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n isRepeated: true,\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n fields: {\n type: \"object\",\n displayName: \"Fields\",\n description: \"List of strings containing the fields to be included\",\n },\n maxRecords: {\n type: \"number\",\n displayName: \"Max Records\",\n description:\n \"The maximum total number of records that will be returned\",\n defaultValueHint: 100,\n max: 100,\n min: 1,\n },\n view: {\n type: \"string\",\n displayName: \"View\",\n description:\n \"The name or ID of a view in the table. If set, only records from that view will be returned\",\n },\n sort: {\n type: \"object\",\n displayName: \"Sort\",\n description:\n 'A list of Airtable sort objects that specifies how the records will be ordered. Each sort object must have a field key specifying the name of the field to sort on, and an optional direction key that is either \"asc\" or \"desc\". The default direction is \"asc\"',\n },\n filterByFormula: {\n type: \"string\",\n displayName: \"Filter by Formula\",\n description: \"An Airtable formula used to filter records\",\n },\n },\n };\n\nexport function registerAirtableCollection(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableCollectionMeta?: CodeComponentMeta<AirtableCollectionProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n } else {\n registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n }\n}\n\nexport const airtableCredentialsProviderMeta: GlobalContextMeta<AirtableCredentialsProviderProps> =\n {\n name: \"hostless-airtable-credentials-provider\",\n displayName: \"Airtable Credentials Provider\",\n importPath: thisModule,\n importName: \"AirtableCredentialsProvider\",\n props: {\n dataSource: {\n type: \"dataSource\",\n dataSource: \"airtable\",\n displayName: \"Data Source\",\n description: \"The Airtable Data Source to use\",\n },\n host: {\n type: \"string\",\n displayName: \"Host\",\n description: \"Plasmic Server-Data URL\",\n defaultValueHint: defaultHost,\n },\n },\n };\n\nexport function registerAirtableCredentialsProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customAirtableCredentialsProviderMeta?: GlobalContextMeta<AirtableCredentialsProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n } else {\n registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n }\n}\n","export * from \"./RecordData\";\nimport {\n registerAirtableCollection,\n registerAirtableCredentialsProvider,\n registerAirtableRecord,\n registerAirtableRecordField,\n} from \"./RecordData\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n registerAirtableCollection(loader);\n registerAirtableCredentialsProvider(loader);\n registerAirtableRecord(loader);\n registerAirtableRecordField(loader);\n}\n"],"names":["defaultHost","CredentialsContext","React","createContext","undefined","AirtableRecord","_ref","_data$error","table","record","children","credentialsContext","useContext","dataSourceId","id","base","host","data","usePlasmicQueryData","JSON","stringify","_asyncToGenerator","_regeneratorRuntime","mark","_callee","url","wrap","_context","prev","next","Error","encodeURIComponent","fetch","method","sent","json","abrupt","fields","stop","error","message","DataProvider","name","contextKey","AirtableRecordField","_ref3","val","className","field","style","setControlContextData","useSelector","Object","keys","filename","AirtableCollection","_ref4","props","_objectWithoutPropertiesLoose","_excluded","searchArray","forEach","f","push","prop","sort","v","i","direction","search","length","join","_usePlasmicQueryData","_callee2","_context2","records","isLoading","map","index","key","repeatedElement","AirtableCredentialsProvider","_ref6","dataSource","maybeHost","usePlasmicCanvasContext","Provider","value","_extends","thisModule","airtableRecordMeta","displayName","importPath","importName","providesData","type","defaultValue","description","registerAirtableRecord","loader","customAirtableRecordMeta","registerComponent","airtableRecordFieldMeta","defaultValueHint","options","_props","registerAirtableRecordField","customAirtableRecordFieldMeta","airtableCollectionMeta","isRepeated","maxRecords","max","min","view","filterByFormula","registerAirtableCollection","customAirtableCollectionMeta","airtableCredentialsProviderMeta","registerAirtableCredentialsProvider","customAirtableCredentialsProviderMeta","registerGlobalContext"],"mappings":"ytOAgBMA,EAAc,6BAQdC,EAAqBC,EAAMC,mBAC/BC,YAYcC,EAAcC,OAkCPC,EAjCrBC,EAAKF,EAALE,MACAC,EAAMH,EAANG,OACAC,EAAQJ,EAARI,SAEMC,EAAqBT,EAAMU,WAAWX,GAEtCY,EAAeF,GAAsBA,EAAmBG,GACxDC,EAAOJ,GAAsBA,EAAmBI,KAChDC,EAAQL,GAAsBA,EAAmBK,MAAShB,EAE1DiB,EAAOC,sBACXC,KAAKC,UAAU,CAAC,iBAAkBJ,EAAMD,EAAMP,EAAOC,EAAQI,IAAcQ,EAAAC,IAAAC,MAC3E,SAAAC,IAAA,IAAAC,EAAA,OAAAH,IAAAI,eAAAC,GAAA,cAAAA,EAAAC,KAAAD,EAAAE,MAAA,OAAA,GACOd,GAASF,GAAYc,EAAAE,OAAA,MAAA,MAClB,IAAIC,MACR,2FACD,OAAA,GAEEtB,GAAKmB,EAAAE,OAAA,MAAA,MACF,IAAIC,MAAM,4CAA2C,OAAA,GAExDrB,GAAMkB,EAAAE,OAAA,MAAA,MACH,IAAIC,MAAM,2CAA0C,OAK9B,OAFxBL,EAAST,wCAA0Ce,uBADpChB,MAAQP,MAASC,oBAGpBI,EAAYc,EAAAE,QACTG,MAAMP,EAAK,CAAEQ,OAAQ,QAAQ,QAAA,OAAAN,EAAAE,QAAAF,EAAAO,KAAEC,OAAI,QAAA,OAAAR,EAAAS,gBAAAT,EAAAO,KACrDG,QAAoB,QAAA,UAAA,OAAAV,EAAAW,UAAAd,QAI3B,MAAI,UAAWP,EACNf,4CAAWe,EAAKsB,cAALhC,EAAYiC,SAG1B,SAAUvB,EAKdf,gBAACuC,gBAAaC,KAAMC,EAAY1B,KAAMA,EAAKA,MACxCP,GALIR,uCAUX,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Y,KAAM,aACNZ,WAAY,WACZQ,YAAa,cACbM,YAAa,mCAEfjF,KAAM,CACJ+E,KAAM,SACNJ,YAAa,OACbM,YAAa,0BACbM,iBAAkBvG,cAKVsH,EACdnB,EACAoB,GAEIpB,EACFA,EAAOqB,sBACLvC,QACAsC,EAAAA,EAAyCF,GAG3CG,EACEvC,QACAsC,EAAAA,EAAyCF,8bCrbnBlB,GAI1BgB,EAA2BhB,GAC3BmB,EAAoCnB,GACpCD,EAAuBC,GACvBO,EAA4BP"}
@@ -1 +1 @@
1
- {"version":3,"file":"airtable.esm.js","sources":["../src/RecordData.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n repeatedElement,\n usePlasmicCanvasContext,\n useSelector,\n} from \"@plasmicapp/host\";\nimport registerComponent, {\n CanvasComponentProps,\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport React from \"react\";\n\nconst defaultHost = \"https://studio.plasmic.app\";\n\nexport interface DataSourceInfo {\n id: string;\n base: string;\n host?: string;\n}\n\nconst CredentialsContext = React.createContext<DataSourceInfo | undefined>(\n undefined\n);\n\ninterface RecordData {\n [field: string]: string | { id: string; url: string; filename: string }[];\n}\n\nexport interface AirtableRecordProps {\n table: string;\n record: string;\n}\n\nexport function AirtableRecord({\n table,\n record,\n children,\n}: React.PropsWithChildren<AirtableRecordProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const data = usePlasmicQueryData(\n JSON.stringify([\"AirtableRecord\", host, base, table, record, dataSourceId]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableRecord is missing the table name\");\n }\n if (!record) {\n throw new Error(\"AirtableRecord is missing the record ID\");\n }\n const pathname = `/${base}/${table}/${record}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json())\n .fields as RecordData;\n }\n );\n\n if (\"error\" in data) {\n return <p>Error: {data.error?.message}</p>;\n }\n\n if (!(\"data\" in data)) {\n return <p>Loading...</p>;\n }\n\n return (\n <DataProvider name={contextKey} data={data.data}>\n {children}\n </DataProvider>\n );\n}\n\nconst contextKey = \"__airtableRecord\";\n\nfunction useRecord() {\n return useSelector(contextKey) as RecordData | undefined;\n}\n\nexport interface AirtableRecordFieldProps\n extends CanvasComponentProps<RecordData | undefined> {\n className?: string;\n style?: React.CSSProperties;\n field?: string;\n}\n\nexport function AirtableRecordField({\n className,\n field,\n style,\n setControlContextData,\n}: AirtableRecordFieldProps) {\n const record = useRecord();\n setControlContextData?.(record);\n\n return (\n <div className={className} style={style}>\n {record\n ? (() => {\n const val = record[field || Object.keys(record)[0]];\n if (val && typeof val === \"object\") {\n return \"Attachment \" + val[0].filename;\n }\n return val;\n })()\n : \"Error: Must provide a record to AirtableRecordField\"}\n </div>\n );\n}\n\nexport interface AirtableCollectionProps {\n table: string;\n fields?: string[];\n filterByFormula?: string;\n maxRecords?: number;\n pageSize?: number;\n sort?: {\n field: string;\n direction?: \"asc\" | \"desc\";\n }[];\n view?: string;\n}\n\nexport function AirtableCollection({\n table,\n children,\n ...props\n}: React.PropsWithChildren<AirtableCollectionProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const searchArray: string[] = [];\n if (props.fields) {\n props.fields.forEach((f) =>\n searchArray.push(\n `${encodeURIComponent(`fields[]`)}=${encodeURIComponent(`${f}`)}`\n )\n );\n }\n ([\"filterByFormula\", \"maxRecords\", \"pageSize\", \"view\"] as const).forEach(\n (prop) => {\n if (props[prop]) {\n searchArray.push(\n `${encodeURIComponent(`${prop}`)}=${encodeURIComponent(\n `${props[prop]}`\n )}`\n );\n }\n }\n );\n if (props.sort) {\n props.sort.forEach((v, i) => {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][field]`)}=${encodeURIComponent(\n `${v.field}`\n )}`\n );\n if (v.direction) {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][direction]`)}=${encodeURIComponent(\n `${v.direction}`\n )}`\n );\n }\n });\n }\n\n const search = searchArray.length === 0 ? \"\" : \"?\" + searchArray.join(\"&\");\n\n const { data, error, isLoading } = usePlasmicQueryData(\n JSON.stringify([\n \"AirtableCollection\",\n host,\n base,\n table,\n search,\n dataSourceId,\n ]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableCollection is missing the table name\");\n }\n const pathname = `/${base}/${table}${search}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json()).records as {\n fields: RecordData;\n id: string;\n }[];\n }\n );\n\n if (error) {\n return <p>Error: {error.message}</p>;\n }\n\n if (isLoading) {\n return <p>Loading...</p>;\n }\n\n return (\n <>\n {(data ?? []).map((record, index) => (\n <DataProvider key={record.id} name={contextKey} data={record.fields}>\n {repeatedElement(index, children)}\n </DataProvider>\n ))}\n </>\n );\n}\n\ninterface AirtableCredentialsProviderProps {\n dataSource: DataSourceInfo;\n host?: string;\n}\n\nexport function AirtableCredentialsProvider({\n dataSource,\n host: maybeHost,\n children,\n}: React.PropsWithChildren<AirtableCredentialsProviderProps>) {\n const inCanvas = usePlasmicCanvasContext();\n if (inCanvas && (!dataSource || !dataSource.id || !dataSource.base)) {\n return (\n <p>\n Error: Missing Data Source. Please select a Data Source from the\n Airtable Credentials Provider\n </p>\n );\n }\n const host = maybeHost || defaultHost;\n return (\n <CredentialsContext.Provider value={{ ...dataSource, host }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\nconst thisModule = \"@plasmicpkgs/airtable\";\n\nexport const airtableRecordMeta: ComponentMeta<AirtableRecordProps> = {\n name: \"hostless-airtable-record\",\n displayName: \"Airtable Record\",\n importPath: thisModule,\n importName: \"AirtableRecord\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n record: {\n type: \"string\",\n displayName: \"Record\",\n description: \"The table record ID\",\n },\n },\n};\n\nexport function registerAirtableRecord(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordMeta?: ComponentMeta<AirtableRecordProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n } else {\n registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n }\n}\n\nexport const airtableRecordFieldMeta: ComponentMeta<AirtableRecordFieldProps> = {\n name: \"hostless-airtable-record-field\",\n displayName: \"Airtable Record Field\",\n importPath: thisModule,\n importName: \"AirtableRecordField\",\n props: {\n field: {\n type: \"choice\",\n displayName: \"Field Name\",\n defaultValueHint: \"The first field\",\n options: (_props, data) => {\n return data ? Object.keys(data) : [\"Data unavailable\"];\n },\n },\n },\n};\n\nexport function registerAirtableRecordField(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordFieldMeta?: ComponentMeta<AirtableRecordFieldProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n } else {\n registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n }\n}\n\nexport const airtableCollectionMeta: ComponentMeta<AirtableCollectionProps> = {\n name: \"hostless-airtable-collection\",\n displayName: \"Airtable Collection\",\n importPath: thisModule,\n importName: \"AirtableCollection\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n isRepeated: true,\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n fields: {\n type: \"object\",\n displayName: \"Fields\",\n description: \"List of strings containing the fields to be included\",\n },\n maxRecords: {\n type: \"number\",\n displayName: \"Max Records\",\n description: \"The maximum total number of records that will be returned\",\n defaultValueHint: 100,\n max: 100,\n min: 1,\n },\n view: {\n type: \"string\",\n displayName: \"View\",\n description:\n \"The name or ID of a view in the table. If set, only records from that view will be returned\",\n },\n sort: {\n type: \"object\",\n displayName: \"Sort\",\n description:\n 'A list of Airtable sort objects that specifies how the records will be ordered. Each sort object must have a field key specifying the name of the field to sort on, and an optional direction key that is either \"asc\" or \"desc\". The default direction is \"asc\"',\n },\n filterByFormula: {\n type: \"string\",\n displayName: \"Filter by Formula\",\n description: \"An Airtable formula used to filter records\",\n },\n },\n};\n\nexport function registerAirtableCollection(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableCollectionMeta?: ComponentMeta<AirtableCollectionProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n } else {\n registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n }\n}\n\nexport const airtableCredentialsProviderMeta: GlobalContextMeta<AirtableCredentialsProviderProps> = {\n name: \"hostless-airtable-credentials-provider\",\n displayName: \"Airtable Credentials Provider\",\n importPath: thisModule,\n importName: \"AirtableCredentialsProvider\",\n props: {\n dataSource: {\n type: \"dataSource\",\n dataSource: \"airtable\",\n displayName: \"Data Source\",\n description: \"The Airtable Data Source to use\",\n },\n host: {\n type: \"string\",\n displayName: \"Host\",\n description: \"Plasmic Server-Data URL\",\n defaultValueHint: defaultHost,\n },\n },\n};\n\nexport function registerAirtableCredentialsProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customAirtableCredentialsProviderMeta?: GlobalContextMeta<AirtableCredentialsProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n } else {\n registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n }\n}\n","export * from \"./RecordData\";\nimport {\n registerAirtableCollection,\n registerAirtableCredentialsProvider,\n registerAirtableRecord,\n registerAirtableRecordField,\n} from \"./RecordData\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n registerAirtableCollection(loader);\n registerAirtableCredentialsProvider(loader);\n registerAirtableRecord(loader);\n registerAirtableRecordField(loader);\n}\n"],"names":["defaultHost","CredentialsContext","React","createContext","undefined","AirtableRecord","_ref","table","record","children","credentialsContext","useContext","dataSourceId","id","base","host","data","usePlasmicQueryData","JSON","stringify","_asyncToGenerator","_regeneratorRuntime","mark","_callee","pathname","url","wrap","_callee$","_context","prev","next","Error","encodeURIComponent","fetch","method","sent","json","abrupt","fields","stop","_data$error","error","message","DataProvider","name","contextKey","useRecord","useSelector","AirtableRecordField","_ref3","className","field","style","setControlContextData","val","Object","keys","filename","AirtableCollection","_ref4","props","_objectWithoutPropertiesLoose","_excluded","searchArray","forEach","f","push","prop","sort","v","i","direction","search","length","join","_usePlasmicQueryData","_callee2","_callee2$","_context2","records","isLoading","map","index","key","repeatedElement","AirtableCredentialsProvider","_ref6","dataSource","maybeHost","inCanvas","usePlasmicCanvasContext","Provider","value","_extends","thisModule","airtableRecordMeta","displayName","importPath","importName","providesData","type","defaultValue","description","registerAirtableRecord","loader","customAirtableRecordMeta","registerComponent","airtableRecordFieldMeta","defaultValueHint","options","_props","registerAirtableRecordField","customAirtableRecordFieldMeta","airtableCollectionMeta","isRepeated","maxRecords","max","min","view","filterByFormula","registerAirtableCollection","customAirtableCollectionMeta","airtableCredentialsProviderMeta","registerAirtableCredentialsProvider","customAirtableCredentialsProviderMeta","registerGlobalContext","registerAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAMA,WAAW,GAAG,4BAA4B;AAQhD,IAAMC,kBAAkB,gBAAGC,KAAK,CAACC,aAAa,CAC5CC,SAAS,CACV;SAWeC,cAAcA,CAAAC,IAAA;MAC5BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;EAER,IAAMC,kBAAkB,GAAGR,KAAK,CAACS,UAAU,CAACV,kBAAkB,CAAC;EAE/D,IAAMW,YAAY,GAAGF,kBAAkB,IAAIA,kBAAkB,CAACG,EAAE;EAChE,IAAMC,IAAI,GAAGJ,kBAAkB,IAAIA,kBAAkB,CAACI,IAAI;EAC1D,IAAMC,IAAI,GAAIL,kBAAkB,IAAIA,kBAAkB,CAACK,IAAI,IAAKf,WAAW;EAE3E,IAA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B,GAAwD;EAClG9E,IAAI,EAAE,wCAAwC;EAC9CoD,WAAW,EAAE,+BAA+B;EAC5CC,UAAU,EAAEH,UAAU;EACtBI,UAAU,EAAE,6BAA6B;EACzCtC,KAAK,EAAE;IACL2B,UAAU,EAAE;MACVa,IAAI,EAAE,YAAY;MAClBb,UAAU,EAAE,UAAU;MACtBS,WAAW,EAAE,aAAa;MAC1BM,WAAW,EAAE;KACd;IACDvF,IAAI,EAAE;MACJqF,IAAI,EAAE,QAAQ;MACdJ,WAAW,EAAE,MAAM;MACnBM,WAAW,EAAE,yBAAyB;MACtCM,gBAAgB,EAAE5G;;;;SAKR2H,mCAAmCA,CACjDnB,MAAgE,EAChEoB,qCAA2F;EAE3F,IAAIpB,MAAM,EAAE;IACVA,MAAM,CAACqB,qBAAqB,CAC1BxC,2BAA2B,EAC3BuC,qCAAqC,WAArCA,qCAAqC,GAAIF,+BAA+B,CACzE;GACF,MAAM;IACLG,qBAAqB,CACnBxC,2BAA2B,EAC3BuC,qCAAqC,WAArCA,qCAAqC,GAAIF,+BAA+B,CACzE;;AAEL;;SCpbgBI,WAAWA,CAACtB,MAG3B;EACCgB,0BAA0B,CAAChB,MAAM,CAAC;EAClCmB,mCAAmC,CAACnB,MAAM,CAAC;EAC3CD,sBAAsB,CAACC,MAAM,CAAC;EAC9BO,2BAA2B,CAACP,MAAM,CAAC;AACrC;;;;"}
1
+ {"version":3,"file":"airtable.esm.js","sources":["../src/RecordData.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n repeatedElement,\n usePlasmicCanvasContext,\n useSelector,\n} from \"@plasmicapp/host\";\nimport registerComponent, {\n CanvasComponentProps,\n CodeComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@plasmicapp/host/registerGlobalContext\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport React from \"react\";\n\nconst defaultHost = \"https://studio.plasmic.app\";\n\nexport interface DataSourceInfo {\n id: string;\n base: string;\n host?: string;\n}\n\nconst CredentialsContext = React.createContext<DataSourceInfo | undefined>(\n undefined\n);\n\ninterface RecordData {\n [field: string]: string | { id: string; url: string; filename: string }[];\n}\n\nexport interface AirtableRecordProps {\n table: string;\n record: string;\n}\n\nexport function AirtableRecord({\n table,\n record,\n children,\n}: React.PropsWithChildren<AirtableRecordProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const data = usePlasmicQueryData(\n JSON.stringify([\"AirtableRecord\", host, base, table, record, dataSourceId]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableRecord is missing the table name\");\n }\n if (!record) {\n throw new Error(\"AirtableRecord is missing the record ID\");\n }\n const pathname = `/${base}/${table}/${record}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json())\n .fields as RecordData;\n }\n );\n\n if (\"error\" in data) {\n return <p>Error: {data.error?.message}</p>;\n }\n\n if (!(\"data\" in data)) {\n return <p>Loading...</p>;\n }\n\n return (\n <DataProvider name={contextKey} data={data.data}>\n {children}\n </DataProvider>\n );\n}\n\nconst contextKey = \"__airtableRecord\";\n\nfunction useRecord() {\n return useSelector(contextKey) as RecordData | undefined;\n}\n\nexport interface AirtableRecordFieldProps\n extends CanvasComponentProps<RecordData | undefined> {\n className?: string;\n style?: React.CSSProperties;\n field?: string;\n}\n\nexport function AirtableRecordField({\n className,\n field,\n style,\n setControlContextData,\n}: AirtableRecordFieldProps) {\n const record = useRecord();\n setControlContextData?.(record);\n\n return (\n <div className={className} style={style}>\n {record\n ? (() => {\n const val = record[field || Object.keys(record)[0]];\n if (val && typeof val === \"object\") {\n return \"Attachment \" + val[0].filename;\n }\n return val;\n })()\n : \"Error: Must provide a record to AirtableRecordField\"}\n </div>\n );\n}\n\nexport interface AirtableCollectionProps {\n table: string;\n fields?: string[];\n filterByFormula?: string;\n maxRecords?: number;\n pageSize?: number;\n sort?: {\n field: string;\n direction?: \"asc\" | \"desc\";\n }[];\n view?: string;\n}\n\nexport function AirtableCollection({\n table,\n children,\n ...props\n}: React.PropsWithChildren<AirtableCollectionProps>) {\n const credentialsContext = React.useContext(CredentialsContext);\n\n const dataSourceId = credentialsContext && credentialsContext.id;\n const base = credentialsContext && credentialsContext.base;\n const host = (credentialsContext && credentialsContext.host) || defaultHost;\n\n const searchArray: string[] = [];\n if (props.fields) {\n props.fields.forEach((f) =>\n searchArray.push(\n `${encodeURIComponent(`fields[]`)}=${encodeURIComponent(`${f}`)}`\n )\n );\n }\n ([\"filterByFormula\", \"maxRecords\", \"pageSize\", \"view\"] as const).forEach(\n (prop) => {\n if (props[prop]) {\n searchArray.push(\n `${encodeURIComponent(`${prop}`)}=${encodeURIComponent(\n `${props[prop]}`\n )}`\n );\n }\n }\n );\n if (props.sort) {\n props.sort.forEach((v, i) => {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][field]`)}=${encodeURIComponent(\n `${v.field}`\n )}`\n );\n if (v.direction) {\n searchArray.push(\n `${encodeURIComponent(`sort[${i}][direction]`)}=${encodeURIComponent(\n `${v.direction}`\n )}`\n );\n }\n });\n }\n\n const search = searchArray.length === 0 ? \"\" : \"?\" + searchArray.join(\"&\");\n\n const { data, error, isLoading } = usePlasmicQueryData(\n JSON.stringify([\n \"AirtableCollection\",\n host,\n base,\n table,\n search,\n dataSourceId,\n ]),\n async () => {\n if (!base || !dataSourceId) {\n throw new Error(\n \"Missing Data Source. Please select a Data Source from the Airtable Credentials Provider\"\n );\n }\n if (!table) {\n throw new Error(\"AirtableCollection is missing the table name\");\n }\n const pathname = `/${base}/${table}${search}`;\n const url = `${host}/api/v1/server-data/query?pathname=${encodeURIComponent(\n pathname\n )}&dataSourceId=${dataSourceId}`;\n return (await (await fetch(url, { method: \"GET\" })).json()).records as {\n fields: RecordData;\n id: string;\n }[];\n }\n );\n\n if (error) {\n return <p>Error: {error.message}</p>;\n }\n\n if (isLoading) {\n return <p>Loading...</p>;\n }\n\n return (\n <>\n {(data ?? []).map((record, index) => (\n <DataProvider key={record.id} name={contextKey} data={record.fields}>\n {repeatedElement(index, children)}\n </DataProvider>\n ))}\n </>\n );\n}\n\ninterface AirtableCredentialsProviderProps {\n dataSource: DataSourceInfo;\n host?: string;\n}\n\nexport function AirtableCredentialsProvider({\n dataSource,\n host: maybeHost,\n children,\n}: React.PropsWithChildren<AirtableCredentialsProviderProps>) {\n const inCanvas = usePlasmicCanvasContext();\n if (inCanvas && (!dataSource || !dataSource.id || !dataSource.base)) {\n return (\n <p>\n Error: Missing Data Source. Please select a Data Source from the\n Airtable Credentials Provider\n </p>\n );\n }\n const host = maybeHost || defaultHost;\n return (\n <CredentialsContext.Provider value={{ ...dataSource, host }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\nconst thisModule = \"@plasmicpkgs/airtable\";\n\nexport const airtableRecordMeta: CodeComponentMeta<AirtableRecordProps> = {\n name: \"hostless-airtable-record\",\n displayName: \"Airtable Record\",\n importPath: thisModule,\n importName: \"AirtableRecord\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n record: {\n type: \"string\",\n displayName: \"Record\",\n description: \"The table record ID\",\n },\n },\n};\n\nexport function registerAirtableRecord(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordMeta?: CodeComponentMeta<AirtableRecordProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n } else {\n registerComponent(\n AirtableRecord,\n customAirtableRecordMeta ?? airtableRecordMeta\n );\n }\n}\n\nexport const airtableRecordFieldMeta: CodeComponentMeta<AirtableRecordFieldProps> =\n {\n name: \"hostless-airtable-record-field\",\n displayName: \"Airtable Record Field\",\n importPath: thisModule,\n importName: \"AirtableRecordField\",\n props: {\n field: {\n type: \"choice\",\n displayName: \"Field Name\",\n defaultValueHint: \"The first field\",\n options: (_props, data) => {\n return data ? Object.keys(data) : [\"Data unavailable\"];\n },\n },\n },\n };\n\nexport function registerAirtableRecordField(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableRecordFieldMeta?: CodeComponentMeta<AirtableRecordFieldProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n } else {\n registerComponent(\n AirtableRecordField,\n customAirtableRecordFieldMeta ?? airtableRecordFieldMeta\n );\n }\n}\n\nexport const airtableCollectionMeta: CodeComponentMeta<AirtableCollectionProps> =\n {\n name: \"hostless-airtable-collection\",\n displayName: \"Airtable Collection\",\n importPath: thisModule,\n importName: \"AirtableCollection\",\n providesData: true,\n props: {\n children: {\n type: \"slot\",\n isRepeated: true,\n defaultValue: {\n type: \"component\",\n name: \"hostless-airtable-record-field\",\n },\n },\n table: {\n type: \"string\",\n displayName: \"Table Name\",\n description: \"The Airtable table name or ID\",\n },\n fields: {\n type: \"object\",\n displayName: \"Fields\",\n description: \"List of strings containing the fields to be included\",\n },\n maxRecords: {\n type: \"number\",\n displayName: \"Max Records\",\n description:\n \"The maximum total number of records that will be returned\",\n defaultValueHint: 100,\n max: 100,\n min: 1,\n },\n view: {\n type: \"string\",\n displayName: \"View\",\n description:\n \"The name or ID of a view in the table. If set, only records from that view will be returned\",\n },\n sort: {\n type: \"object\",\n displayName: \"Sort\",\n description:\n 'A list of Airtable sort objects that specifies how the records will be ordered. Each sort object must have a field key specifying the name of the field to sort on, and an optional direction key that is either \"asc\" or \"desc\". The default direction is \"asc\"',\n },\n filterByFormula: {\n type: \"string\",\n displayName: \"Filter by Formula\",\n description: \"An Airtable formula used to filter records\",\n },\n },\n };\n\nexport function registerAirtableCollection(\n loader?: { registerComponent: typeof registerComponent },\n customAirtableCollectionMeta?: CodeComponentMeta<AirtableCollectionProps>\n) {\n if (loader) {\n loader.registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n } else {\n registerComponent(\n AirtableCollection,\n customAirtableCollectionMeta ?? airtableCollectionMeta\n );\n }\n}\n\nexport const airtableCredentialsProviderMeta: GlobalContextMeta<AirtableCredentialsProviderProps> =\n {\n name: \"hostless-airtable-credentials-provider\",\n displayName: \"Airtable Credentials Provider\",\n importPath: thisModule,\n importName: \"AirtableCredentialsProvider\",\n props: {\n dataSource: {\n type: \"dataSource\",\n dataSource: \"airtable\",\n displayName: \"Data Source\",\n description: \"The Airtable Data Source to use\",\n },\n host: {\n type: \"string\",\n displayName: \"Host\",\n description: \"Plasmic Server-Data URL\",\n defaultValueHint: defaultHost,\n },\n },\n };\n\nexport function registerAirtableCredentialsProvider(\n loader?: { registerGlobalContext: typeof registerGlobalContext },\n customAirtableCredentialsProviderMeta?: GlobalContextMeta<AirtableCredentialsProviderProps>\n) {\n if (loader) {\n loader.registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n } else {\n registerGlobalContext(\n AirtableCredentialsProvider,\n customAirtableCredentialsProviderMeta ?? airtableCredentialsProviderMeta\n );\n }\n}\n","export * from \"./RecordData\";\nimport {\n registerAirtableCollection,\n registerAirtableCredentialsProvider,\n registerAirtableRecord,\n registerAirtableRecordField,\n} from \"./RecordData\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n registerAirtableCollection(loader);\n registerAirtableCredentialsProvider(loader);\n registerAirtableRecord(loader);\n registerAirtableRecordField(loader);\n}\n"],"names":["defaultHost","CredentialsContext","React","createContext","undefined","AirtableRecord","_ref","table","record","children","credentialsContext","useContext","dataSourceId","id","base","host","data","usePlasmicQueryData","JSON","stringify","_asyncToGenerator","_regeneratorRuntime","mark","_callee","pathname","url","wrap","_callee$","_context","prev","next","Error","encodeURIComponent","fetch","method","sent","json","abrupt","fields","stop","_data$error","error","message","DataProvider","name","contextKey","useRecord","useSelector","AirtableRecordField","_ref3","className","field","style","setControlContextData","val","Object","keys","filename","AirtableCollection","_ref4","props","_objectWithoutPropertiesLoose","_excluded","searchArray","forEach","f","push","prop","sort","v","i","direction","search","length","join","_usePlasmicQueryData","_callee2","_callee2$","_context2","records","isLoading","map","index","key","repeatedElement","AirtableCredentialsProvider","_ref6","dataSource","maybeHost","inCanvas","usePlasmicCanvasContext","Provider","value","_extends","thisModule","airtableRecordMeta","displayName","importPath","importName","providesData","type","defaultValue","description","registerAirtableRecord","loader","customAirtableRecordMeta","registerComponent","airtableRecordFieldMeta","defaultValueHint","options","_props","registerAirtableRecordField","customAirtableRecordFieldMeta","airtableCollectionMeta","isRepeated","maxRecords","max","min","view","filterByFormula","registerAirtableCollection","customAirtableCollectionMeta","airtableCredentialsProviderMeta","registerAirtableCredentialsProvider","customAirtableCredentialsProviderMeta","registerGlobalContext","registerAll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AWA,CAACtB,MAG3B;EACCgB,0BAA0B,CAAChB,MAAM,CAAC;EAClCmB,mCAAmC,CAACnB,MAAM,CAAC;EAC3CD,sBAAsB,CAACC,MAAM,CAAC;EAC9BO,2BAA2B,CAACP,MAAM,CAAC;AACrC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicpkgs/airtable",
3
- "version": "0.0.249",
3
+ "version": "0.0.250",
4
4
  "description": "Plasmic registration call for the HTML5 video element",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,5 +40,5 @@
40
40
  "react": ">=16.8.0",
41
41
  "react-dom": ">=16.8.0"
42
42
  },
43
- "gitHead": "30e1d9c40c46f513d507349568dc16bc5f3e9572"
43
+ "gitHead": "bbba4b6636e69a3441c6dbe4cefb860ed30e826f"
44
44
  }