@plasmicpkgs/airtable 0.0.222 → 0.0.224

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.
@@ -379,7 +379,7 @@ function AirtableRecord(_ref) {
379
379
  var dataSourceId = credentialsContext && credentialsContext.id;
380
380
  var base = credentialsContext && credentialsContext.base;
381
381
  var host$1 = credentialsContext && credentialsContext.host || defaultHost;
382
- var data = query.usePlasmicQueryData(JSON.stringify(["AirtableRecord", host$1, base, table, record, dataSourceId]), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
382
+ var data = query.usePlasmicQueryData(JSON.stringify(["AirtableRecord", host$1, base, table, record, dataSourceId]), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
383
383
  var pathname, url;
384
384
  return _regeneratorRuntime().wrap(function _callee$(_context) {
385
385
  while (1) switch (_context.prev = _context.next) {
@@ -481,7 +481,7 @@ function AirtableCollection(_ref4) {
481
481
  });
482
482
  }
483
483
  var search = searchArray.length === 0 ? "" : "?" + searchArray.join("&");
484
- var _usePlasmicQueryData = query.usePlasmicQueryData(JSON.stringify(["AirtableCollection", host$1, base, table, search, dataSourceId]), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
484
+ var _usePlasmicQueryData = query.usePlasmicQueryData(JSON.stringify(["AirtableCollection", host$1, base, table, search, dataSourceId]), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
485
485
  var pathname, url;
486
486
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
487
487
  while (1) switch (_context2.prev = _context2.next) {
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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pB,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 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,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vD;GACF,MAAM;IACLP,iBAAiB,CACfhD,kBAAkB,EAClB+D,4BAA4B,WAA5BA,4BAA4B,GAAIR,sBAAsB,CACvD;;AAEL;IAEaS,+BAA+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;;;;;;;;;;;;;;;;"}
@@ -373,7 +373,7 @@ function AirtableRecord(_ref) {
373
373
  var dataSourceId = credentialsContext && credentialsContext.id;
374
374
  var base = credentialsContext && credentialsContext.base;
375
375
  var host = credentialsContext && credentialsContext.host || defaultHost;
376
- var data = usePlasmicQueryData(JSON.stringify(["AirtableRecord", host, base, table, record, dataSourceId]), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
376
+ var data = usePlasmicQueryData(JSON.stringify(["AirtableRecord", host, base, table, record, dataSourceId]), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
377
377
  var pathname, url;
378
378
  return _regeneratorRuntime().wrap(function _callee$(_context) {
379
379
  while (1) switch (_context.prev = _context.next) {
@@ -475,7 +475,7 @@ function AirtableCollection(_ref4) {
475
475
  });
476
476
  }
477
477
  var search = searchArray.length === 0 ? "" : "?" + searchArray.join("&");
478
- var _usePlasmicQueryData = usePlasmicQueryData(JSON.stringify(["AirtableCollection", host, base, table, search, dataSourceId]), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
478
+ var _usePlasmicQueryData = usePlasmicQueryData(JSON.stringify(["AirtableCollection", host, base, table, search, dataSourceId]), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
479
479
  var pathname, url;
480
480
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
481
481
  while (1) switch (_context2.prev = _context2.next) {
@@ -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,KA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C;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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicpkgs/airtable",
3
- "version": "0.0.222",
3
+ "version": "0.0.224",
4
4
  "description": "Plasmic registration call for the HTML5 video element",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "analyze": "size-limit --why"
29
29
  },
30
30
  "devDependencies": {
31
- "@plasmicapp/host": "1.0.208",
31
+ "@plasmicapp/host": "1.0.210",
32
32
  "@size-limit/preset-small-lib": "^4.11.0",
33
33
  "@types/node": "^14.0.26",
34
34
  "@types/react": "^18.2.33",
@@ -42,5 +42,5 @@
42
42
  "react": ">=16.8.0",
43
43
  "react-dom": ">=16.8.0"
44
44
  },
45
- "gitHead": "879304149b902b453a47fe674997fcad01ae4af8"
45
+ "gitHead": "7f923856013e0efa4eb893fa16c2f48bd4edc9c3"
46
46
  }