@daouypkgs/airtable 0.0.249
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/RecordData.d.ts +61 -0
- package/dist/airtable.cjs.development.js +500 -0
- package/dist/airtable.cjs.development.js.map +1 -0
- package/dist/airtable.cjs.production.min.js +2 -0
- package/dist/airtable.cjs.production.min.js.map +1 -0
- package/dist/airtable.esm.js +482 -0
- package/dist/airtable.esm.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Daouy components for Airtable integration.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import registerComponent, { CanvasComponentProps, ComponentMeta } from "@daouy/host/registerComponent";
|
|
2
|
+
import registerGlobalContext, { GlobalContextMeta } from "@daouy/host/registerGlobalContext";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export interface DataSourceInfo {
|
|
5
|
+
id: string;
|
|
6
|
+
base: string;
|
|
7
|
+
host?: string;
|
|
8
|
+
}
|
|
9
|
+
interface RecordData {
|
|
10
|
+
[field: string]: string | {
|
|
11
|
+
id: string;
|
|
12
|
+
url: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
export interface AirtableRecordProps {
|
|
17
|
+
table: string;
|
|
18
|
+
record: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function AirtableRecord({ table, record, children, }: React.PropsWithChildren<AirtableRecordProps>): React.JSX.Element;
|
|
21
|
+
export interface AirtableRecordFieldProps extends CanvasComponentProps<RecordData | undefined> {
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: React.CSSProperties;
|
|
24
|
+
field?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function AirtableRecordField({ className, field, style, setControlContextData, }: AirtableRecordFieldProps): React.JSX.Element;
|
|
27
|
+
export interface AirtableCollectionProps {
|
|
28
|
+
table: string;
|
|
29
|
+
fields?: string[];
|
|
30
|
+
filterByFormula?: string;
|
|
31
|
+
maxRecords?: number;
|
|
32
|
+
pageSize?: number;
|
|
33
|
+
sort?: {
|
|
34
|
+
field: string;
|
|
35
|
+
direction?: "asc" | "desc";
|
|
36
|
+
}[];
|
|
37
|
+
view?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function AirtableCollection({ table, children, ...props }: React.PropsWithChildren<AirtableCollectionProps>): React.JSX.Element;
|
|
40
|
+
interface AirtableCredentialsProviderProps {
|
|
41
|
+
dataSource: DataSourceInfo;
|
|
42
|
+
host?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function AirtableCredentialsProvider({ dataSource, host: maybeHost, children, }: React.PropsWithChildren<AirtableCredentialsProviderProps>): React.JSX.Element;
|
|
45
|
+
export declare const airtableRecordMeta: ComponentMeta<AirtableRecordProps>;
|
|
46
|
+
export declare function registerAirtableRecord(loader?: {
|
|
47
|
+
registerComponent: typeof registerComponent;
|
|
48
|
+
}, customAirtableRecordMeta?: ComponentMeta<AirtableRecordProps>): void;
|
|
49
|
+
export declare const airtableRecordFieldMeta: ComponentMeta<AirtableRecordFieldProps>;
|
|
50
|
+
export declare function registerAirtableRecordField(loader?: {
|
|
51
|
+
registerComponent: typeof registerComponent;
|
|
52
|
+
}, customAirtableRecordFieldMeta?: ComponentMeta<AirtableRecordFieldProps>): void;
|
|
53
|
+
export declare const airtableCollectionMeta: ComponentMeta<AirtableCollectionProps>;
|
|
54
|
+
export declare function registerAirtableCollection(loader?: {
|
|
55
|
+
registerComponent: typeof registerComponent;
|
|
56
|
+
}, customAirtableCollectionMeta?: ComponentMeta<AirtableCollectionProps>): void;
|
|
57
|
+
export declare const airtableCredentialsProviderMeta: GlobalContextMeta<AirtableCredentialsProviderProps>;
|
|
58
|
+
export declare function registerAirtableCredentialsProvider(loader?: {
|
|
59
|
+
registerGlobalContext: typeof registerGlobalContext;
|
|
60
|
+
}, customAirtableCredentialsProviderMeta?: GlobalContextMeta<AirtableCredentialsProviderProps>): void;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
var host = require('@daouy/host');
|
|
8
|
+
var registerComponent = _interopDefault(require('@daouy/host/registerComponent'));
|
|
9
|
+
var registerGlobalContext = _interopDefault(require('@daouy/host/registerGlobalContext'));
|
|
10
|
+
var query = require('@daouy/query');
|
|
11
|
+
var React = _interopDefault(require('react'));
|
|
12
|
+
|
|
13
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
14
|
+
try {
|
|
15
|
+
var i = n[a](c),
|
|
16
|
+
u = i.value;
|
|
17
|
+
} catch (n) {
|
|
18
|
+
return void e(n);
|
|
19
|
+
}
|
|
20
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
21
|
+
}
|
|
22
|
+
function _asyncToGenerator(n) {
|
|
23
|
+
return function () {
|
|
24
|
+
var t = this,
|
|
25
|
+
e = arguments;
|
|
26
|
+
return new Promise(function (r, o) {
|
|
27
|
+
var a = n.apply(t, e);
|
|
28
|
+
function _next(n) {
|
|
29
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
30
|
+
}
|
|
31
|
+
function _throw(n) {
|
|
32
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
33
|
+
}
|
|
34
|
+
_next(void 0);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function _extends() {
|
|
39
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
40
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
41
|
+
var t = arguments[e];
|
|
42
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
43
|
+
}
|
|
44
|
+
return n;
|
|
45
|
+
}, _extends.apply(null, arguments);
|
|
46
|
+
}
|
|
47
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
48
|
+
if (null == r) return {};
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
51
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
52
|
+
t[n] = r[n];
|
|
53
|
+
}
|
|
54
|
+
return t;
|
|
55
|
+
}
|
|
56
|
+
function _regenerator() {
|
|
57
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
58
|
+
var e,
|
|
59
|
+
t,
|
|
60
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
61
|
+
n = r.iterator || "@@iterator",
|
|
62
|
+
o = r.toStringTag || "@@toStringTag";
|
|
63
|
+
function i(r, n, o, i) {
|
|
64
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
65
|
+
u = Object.create(c.prototype);
|
|
66
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
67
|
+
var i,
|
|
68
|
+
c,
|
|
69
|
+
u,
|
|
70
|
+
f = 0,
|
|
71
|
+
p = o || [],
|
|
72
|
+
y = !1,
|
|
73
|
+
G = {
|
|
74
|
+
p: 0,
|
|
75
|
+
n: 0,
|
|
76
|
+
v: e,
|
|
77
|
+
a: d,
|
|
78
|
+
f: d.bind(e, 4),
|
|
79
|
+
d: function (t, r) {
|
|
80
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
function d(r, n) {
|
|
84
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
85
|
+
var o,
|
|
86
|
+
i = p[t],
|
|
87
|
+
d = G.p,
|
|
88
|
+
l = i[2];
|
|
89
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
90
|
+
}
|
|
91
|
+
if (o || r > 1) return a;
|
|
92
|
+
throw y = !0, n;
|
|
93
|
+
}
|
|
94
|
+
return function (o, p, l) {
|
|
95
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
96
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
97
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
98
|
+
try {
|
|
99
|
+
if (f = 2, i) {
|
|
100
|
+
if (c || (o = "next"), t = i[o]) {
|
|
101
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
102
|
+
if (!t.done) return t;
|
|
103
|
+
u = t.value, c < 2 && (c = 0);
|
|
104
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
105
|
+
i = e;
|
|
106
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
107
|
+
} catch (t) {
|
|
108
|
+
i = e, c = 1, u = t;
|
|
109
|
+
} finally {
|
|
110
|
+
f = 1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
value: t,
|
|
115
|
+
done: y
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
}(r, o, i), !0), u;
|
|
119
|
+
}
|
|
120
|
+
var a = {};
|
|
121
|
+
function Generator() {}
|
|
122
|
+
function GeneratorFunction() {}
|
|
123
|
+
function GeneratorFunctionPrototype() {}
|
|
124
|
+
t = Object.getPrototypeOf;
|
|
125
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
126
|
+
return this;
|
|
127
|
+
}), t),
|
|
128
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
129
|
+
function f(e) {
|
|
130
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
131
|
+
}
|
|
132
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
133
|
+
return this;
|
|
134
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
135
|
+
return "[object Generator]";
|
|
136
|
+
}), (_regenerator = function () {
|
|
137
|
+
return {
|
|
138
|
+
w: i,
|
|
139
|
+
m: f
|
|
140
|
+
};
|
|
141
|
+
})();
|
|
142
|
+
}
|
|
143
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
144
|
+
var i = Object.defineProperty;
|
|
145
|
+
try {
|
|
146
|
+
i({}, "", {});
|
|
147
|
+
} catch (e) {
|
|
148
|
+
i = 0;
|
|
149
|
+
}
|
|
150
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
151
|
+
function o(r, n) {
|
|
152
|
+
_regeneratorDefine(e, r, function (e) {
|
|
153
|
+
return this._invoke(r, n, e);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
r ? i ? i(e, r, {
|
|
157
|
+
value: n,
|
|
158
|
+
enumerable: !t,
|
|
159
|
+
configurable: !t,
|
|
160
|
+
writable: !t
|
|
161
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
162
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
var _excluded = ["table", "children"];
|
|
166
|
+
var defaultHost = "https://studio.quocuy.cloud";
|
|
167
|
+
var CredentialsContext = /*#__PURE__*/React.createContext(undefined);
|
|
168
|
+
function AirtableRecord(_ref) {
|
|
169
|
+
var table = _ref.table,
|
|
170
|
+
record = _ref.record,
|
|
171
|
+
children = _ref.children;
|
|
172
|
+
var credentialsContext = React.useContext(CredentialsContext);
|
|
173
|
+
var dataSourceId = credentialsContext && credentialsContext.id;
|
|
174
|
+
var base = credentialsContext && credentialsContext.base;
|
|
175
|
+
var host$1 = credentialsContext && credentialsContext.host || defaultHost;
|
|
176
|
+
var data = query.useDaouyQueryData(JSON.stringify(["AirtableRecord", host$1, base, table, record, dataSourceId]), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
177
|
+
var pathname, url;
|
|
178
|
+
return _regenerator().w(function (_context) {
|
|
179
|
+
while (1) switch (_context.n) {
|
|
180
|
+
case 0:
|
|
181
|
+
if (!(!base || !dataSourceId)) {
|
|
182
|
+
_context.n = 1;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
throw new Error("Missing Data Source. Please select a Data Source from the Airtable Credentials Provider");
|
|
186
|
+
case 1:
|
|
187
|
+
if (table) {
|
|
188
|
+
_context.n = 2;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
throw new Error("AirtableRecord is missing the table name");
|
|
192
|
+
case 2:
|
|
193
|
+
if (record) {
|
|
194
|
+
_context.n = 3;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
throw new Error("AirtableRecord is missing the record ID");
|
|
198
|
+
case 3:
|
|
199
|
+
pathname = "/" + base + "/" + table + "/" + record;
|
|
200
|
+
url = host$1 + "/api/v1/server-data/query?pathname=" + encodeURIComponent(pathname) + "&dataSourceId=" + dataSourceId;
|
|
201
|
+
_context.n = 4;
|
|
202
|
+
return fetch(url, {
|
|
203
|
+
method: "GET"
|
|
204
|
+
});
|
|
205
|
+
case 4:
|
|
206
|
+
_context.n = 5;
|
|
207
|
+
return _context.v.json();
|
|
208
|
+
case 5:
|
|
209
|
+
return _context.a(2, _context.v.fields);
|
|
210
|
+
}
|
|
211
|
+
}, _callee);
|
|
212
|
+
})));
|
|
213
|
+
if ("error" in data) {
|
|
214
|
+
var _data$error;
|
|
215
|
+
return React.createElement("p", null, "Error: ", (_data$error = data.error) == null ? void 0 : _data$error.message);
|
|
216
|
+
}
|
|
217
|
+
if (!("data" in data)) {
|
|
218
|
+
return React.createElement("p", null, "Loading...");
|
|
219
|
+
}
|
|
220
|
+
return React.createElement(host.DataProvider, {
|
|
221
|
+
name: contextKey,
|
|
222
|
+
data: data.data
|
|
223
|
+
}, children);
|
|
224
|
+
}
|
|
225
|
+
var contextKey = "__airtableRecord";
|
|
226
|
+
function useRecord() {
|
|
227
|
+
return host.useSelector(contextKey);
|
|
228
|
+
}
|
|
229
|
+
function AirtableRecordField(_ref3) {
|
|
230
|
+
var className = _ref3.className,
|
|
231
|
+
field = _ref3.field,
|
|
232
|
+
style = _ref3.style,
|
|
233
|
+
setControlContextData = _ref3.setControlContextData;
|
|
234
|
+
var record = useRecord();
|
|
235
|
+
setControlContextData == null || setControlContextData(record);
|
|
236
|
+
return React.createElement("div", {
|
|
237
|
+
className: className,
|
|
238
|
+
style: style
|
|
239
|
+
}, record ? function () {
|
|
240
|
+
var val = record[field || Object.keys(record)[0]];
|
|
241
|
+
if (val && typeof val === "object") {
|
|
242
|
+
return "Attachment " + val[0].filename;
|
|
243
|
+
}
|
|
244
|
+
return val;
|
|
245
|
+
}() : "Error: Must provide a record to AirtableRecordField");
|
|
246
|
+
}
|
|
247
|
+
function AirtableCollection(_ref4) {
|
|
248
|
+
var table = _ref4.table,
|
|
249
|
+
children = _ref4.children,
|
|
250
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
251
|
+
var credentialsContext = React.useContext(CredentialsContext);
|
|
252
|
+
var dataSourceId = credentialsContext && credentialsContext.id;
|
|
253
|
+
var base = credentialsContext && credentialsContext.base;
|
|
254
|
+
var host$1 = credentialsContext && credentialsContext.host || defaultHost;
|
|
255
|
+
var searchArray = [];
|
|
256
|
+
if (props.fields) {
|
|
257
|
+
props.fields.forEach(function (f) {
|
|
258
|
+
return searchArray.push(encodeURIComponent("fields[]") + "=" + encodeURIComponent("" + f));
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
["filterByFormula", "maxRecords", "pageSize", "view"].forEach(function (prop) {
|
|
262
|
+
if (props[prop]) {
|
|
263
|
+
searchArray.push(encodeURIComponent("" + prop) + "=" + encodeURIComponent("" + props[prop]));
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
if (props.sort) {
|
|
267
|
+
props.sort.forEach(function (v, i) {
|
|
268
|
+
searchArray.push(encodeURIComponent("sort[" + i + "][field]") + "=" + encodeURIComponent("" + v.field));
|
|
269
|
+
if (v.direction) {
|
|
270
|
+
searchArray.push(encodeURIComponent("sort[" + i + "][direction]") + "=" + encodeURIComponent("" + v.direction));
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
var search = searchArray.length === 0 ? "" : "?" + searchArray.join("&");
|
|
275
|
+
var _useDaouyQueryData = query.useDaouyQueryData(JSON.stringify(["AirtableCollection", host$1, base, table, search, dataSourceId]), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
276
|
+
var pathname, url;
|
|
277
|
+
return _regenerator().w(function (_context2) {
|
|
278
|
+
while (1) switch (_context2.n) {
|
|
279
|
+
case 0:
|
|
280
|
+
if (!(!base || !dataSourceId)) {
|
|
281
|
+
_context2.n = 1;
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
throw new Error("Missing Data Source. Please select a Data Source from the Airtable Credentials Provider");
|
|
285
|
+
case 1:
|
|
286
|
+
if (table) {
|
|
287
|
+
_context2.n = 2;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
throw new Error("AirtableCollection is missing the table name");
|
|
291
|
+
case 2:
|
|
292
|
+
pathname = "/" + base + "/" + table + search;
|
|
293
|
+
url = host$1 + "/api/v1/server-data/query?pathname=" + encodeURIComponent(pathname) + "&dataSourceId=" + dataSourceId;
|
|
294
|
+
_context2.n = 3;
|
|
295
|
+
return fetch(url, {
|
|
296
|
+
method: "GET"
|
|
297
|
+
});
|
|
298
|
+
case 3:
|
|
299
|
+
_context2.n = 4;
|
|
300
|
+
return _context2.v.json();
|
|
301
|
+
case 4:
|
|
302
|
+
return _context2.a(2, _context2.v.records);
|
|
303
|
+
}
|
|
304
|
+
}, _callee2);
|
|
305
|
+
}))),
|
|
306
|
+
data = _useDaouyQueryData.data,
|
|
307
|
+
error = _useDaouyQueryData.error,
|
|
308
|
+
isLoading = _useDaouyQueryData.isLoading;
|
|
309
|
+
if (error) {
|
|
310
|
+
return React.createElement("p", null, "Error: ", error.message);
|
|
311
|
+
}
|
|
312
|
+
if (isLoading) {
|
|
313
|
+
return React.createElement("p", null, "Loading...");
|
|
314
|
+
}
|
|
315
|
+
return React.createElement(React.Fragment, null, (data != null ? data : []).map(function (record, index) {
|
|
316
|
+
return React.createElement(host.DataProvider, {
|
|
317
|
+
key: record.id,
|
|
318
|
+
name: contextKey,
|
|
319
|
+
data: record.fields
|
|
320
|
+
}, host.repeatedElement(index, children));
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
function AirtableCredentialsProvider(_ref6) {
|
|
324
|
+
var dataSource = _ref6.dataSource,
|
|
325
|
+
maybeHost = _ref6.host,
|
|
326
|
+
children = _ref6.children;
|
|
327
|
+
var inCanvas = host.useDaouyCanvasContext();
|
|
328
|
+
if (inCanvas && (!dataSource || !dataSource.id || !dataSource.base)) {
|
|
329
|
+
return React.createElement("p", null, "Error: Missing Data Source. Please select a Data Source from the Airtable Credentials Provider");
|
|
330
|
+
}
|
|
331
|
+
var host$1 = maybeHost || defaultHost;
|
|
332
|
+
return React.createElement(CredentialsContext.Provider, {
|
|
333
|
+
value: _extends({}, dataSource, {
|
|
334
|
+
host: host$1
|
|
335
|
+
})
|
|
336
|
+
}, children);
|
|
337
|
+
}
|
|
338
|
+
var thisModule = "@daouypkgs/airtable";
|
|
339
|
+
var airtableRecordMeta = {
|
|
340
|
+
name: "hostless-airtable-record",
|
|
341
|
+
displayName: "Airtable Record",
|
|
342
|
+
importPath: thisModule,
|
|
343
|
+
importName: "AirtableRecord",
|
|
344
|
+
providesData: true,
|
|
345
|
+
props: {
|
|
346
|
+
children: {
|
|
347
|
+
type: "slot",
|
|
348
|
+
defaultValue: {
|
|
349
|
+
type: "component",
|
|
350
|
+
name: "hostless-airtable-record-field"
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
table: {
|
|
354
|
+
type: "string",
|
|
355
|
+
displayName: "Table Name",
|
|
356
|
+
description: "The Airtable table name or ID"
|
|
357
|
+
},
|
|
358
|
+
record: {
|
|
359
|
+
type: "string",
|
|
360
|
+
displayName: "Record",
|
|
361
|
+
description: "The table record ID"
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
function registerAirtableRecord(loader, customAirtableRecordMeta) {
|
|
366
|
+
if (loader) {
|
|
367
|
+
loader.registerComponent(AirtableRecord, customAirtableRecordMeta != null ? customAirtableRecordMeta : airtableRecordMeta);
|
|
368
|
+
} else {
|
|
369
|
+
registerComponent(AirtableRecord, customAirtableRecordMeta != null ? customAirtableRecordMeta : airtableRecordMeta);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
var airtableRecordFieldMeta = {
|
|
373
|
+
name: "hostless-airtable-record-field",
|
|
374
|
+
displayName: "Airtable Record Field",
|
|
375
|
+
importPath: thisModule,
|
|
376
|
+
importName: "AirtableRecordField",
|
|
377
|
+
props: {
|
|
378
|
+
field: {
|
|
379
|
+
type: "choice",
|
|
380
|
+
displayName: "Field Name",
|
|
381
|
+
defaultValueHint: "The first field",
|
|
382
|
+
options: function options(_props, data) {
|
|
383
|
+
return data ? Object.keys(data) : ["Data unavailable"];
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
function registerAirtableRecordField(loader, customAirtableRecordFieldMeta) {
|
|
389
|
+
if (loader) {
|
|
390
|
+
loader.registerComponent(AirtableRecordField, customAirtableRecordFieldMeta != null ? customAirtableRecordFieldMeta : airtableRecordFieldMeta);
|
|
391
|
+
} else {
|
|
392
|
+
registerComponent(AirtableRecordField, customAirtableRecordFieldMeta != null ? customAirtableRecordFieldMeta : airtableRecordFieldMeta);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
var airtableCollectionMeta = {
|
|
396
|
+
name: "hostless-airtable-collection",
|
|
397
|
+
displayName: "Airtable Collection",
|
|
398
|
+
importPath: thisModule,
|
|
399
|
+
importName: "AirtableCollection",
|
|
400
|
+
providesData: true,
|
|
401
|
+
props: {
|
|
402
|
+
children: {
|
|
403
|
+
type: "slot",
|
|
404
|
+
isRepeated: true,
|
|
405
|
+
defaultValue: {
|
|
406
|
+
type: "component",
|
|
407
|
+
name: "hostless-airtable-record-field"
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
table: {
|
|
411
|
+
type: "string",
|
|
412
|
+
displayName: "Table Name",
|
|
413
|
+
description: "The Airtable table name or ID"
|
|
414
|
+
},
|
|
415
|
+
fields: {
|
|
416
|
+
type: "object",
|
|
417
|
+
displayName: "Fields",
|
|
418
|
+
description: "List of strings containing the fields to be included"
|
|
419
|
+
},
|
|
420
|
+
maxRecords: {
|
|
421
|
+
type: "number",
|
|
422
|
+
displayName: "Max Records",
|
|
423
|
+
description: "The maximum total number of records that will be returned",
|
|
424
|
+
defaultValueHint: 100,
|
|
425
|
+
max: 100,
|
|
426
|
+
min: 1
|
|
427
|
+
},
|
|
428
|
+
view: {
|
|
429
|
+
type: "string",
|
|
430
|
+
displayName: "View",
|
|
431
|
+
description: "The name or ID of a view in the table. If set, only records from that view will be returned"
|
|
432
|
+
},
|
|
433
|
+
sort: {
|
|
434
|
+
type: "object",
|
|
435
|
+
displayName: "Sort",
|
|
436
|
+
description: '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"'
|
|
437
|
+
},
|
|
438
|
+
filterByFormula: {
|
|
439
|
+
type: "string",
|
|
440
|
+
displayName: "Filter by Formula",
|
|
441
|
+
description: "An Airtable formula used to filter records"
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
function registerAirtableCollection(loader, customAirtableCollectionMeta) {
|
|
446
|
+
if (loader) {
|
|
447
|
+
loader.registerComponent(AirtableCollection, customAirtableCollectionMeta != null ? customAirtableCollectionMeta : airtableCollectionMeta);
|
|
448
|
+
} else {
|
|
449
|
+
registerComponent(AirtableCollection, customAirtableCollectionMeta != null ? customAirtableCollectionMeta : airtableCollectionMeta);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
var airtableCredentialsProviderMeta = {
|
|
453
|
+
name: "hostless-airtable-credentials-provider",
|
|
454
|
+
displayName: "Airtable Credentials Provider",
|
|
455
|
+
importPath: thisModule,
|
|
456
|
+
importName: "AirtableCredentialsProvider",
|
|
457
|
+
props: {
|
|
458
|
+
dataSource: {
|
|
459
|
+
type: "dataSource",
|
|
460
|
+
dataSource: "airtable",
|
|
461
|
+
displayName: "Data Source",
|
|
462
|
+
description: "The Airtable Data Source to use"
|
|
463
|
+
},
|
|
464
|
+
host: {
|
|
465
|
+
type: "string",
|
|
466
|
+
displayName: "Host",
|
|
467
|
+
description: "Daouy Server-Data URL",
|
|
468
|
+
defaultValueHint: defaultHost
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
function registerAirtableCredentialsProvider(loader, customAirtableCredentialsProviderMeta) {
|
|
473
|
+
if (loader) {
|
|
474
|
+
loader.registerGlobalContext(AirtableCredentialsProvider, customAirtableCredentialsProviderMeta != null ? customAirtableCredentialsProviderMeta : airtableCredentialsProviderMeta);
|
|
475
|
+
} else {
|
|
476
|
+
registerGlobalContext(AirtableCredentialsProvider, customAirtableCredentialsProviderMeta != null ? customAirtableCredentialsProviderMeta : airtableCredentialsProviderMeta);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function registerAll(loader) {
|
|
481
|
+
registerAirtableCollection(loader);
|
|
482
|
+
registerAirtableCredentialsProvider(loader);
|
|
483
|
+
registerAirtableRecord(loader);
|
|
484
|
+
registerAirtableRecordField(loader);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
exports.AirtableCollection = AirtableCollection;
|
|
488
|
+
exports.AirtableCredentialsProvider = AirtableCredentialsProvider;
|
|
489
|
+
exports.AirtableRecord = AirtableRecord;
|
|
490
|
+
exports.AirtableRecordField = AirtableRecordField;
|
|
491
|
+
exports.airtableCollectionMeta = airtableCollectionMeta;
|
|
492
|
+
exports.airtableCredentialsProviderMeta = airtableCredentialsProviderMeta;
|
|
493
|
+
exports.airtableRecordFieldMeta = airtableRecordFieldMeta;
|
|
494
|
+
exports.airtableRecordMeta = airtableRecordMeta;
|
|
495
|
+
exports.registerAirtableCollection = registerAirtableCollection;
|
|
496
|
+
exports.registerAirtableCredentialsProvider = registerAirtableCredentialsProvider;
|
|
497
|
+
exports.registerAirtableRecord = registerAirtableRecord;
|
|
498
|
+
exports.registerAirtableRecordField = registerAirtableRecordField;
|
|
499
|
+
exports.registerAll = registerAll;
|
|
500
|
+
//# sourceMappingURL=airtable.cjs.development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"airtable.cjs.development.js","sources":["../src/RecordData.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n repeatedElement,\n useDaouyCanvasContext,\n useSelector,\n} from \"@daouy/host\";\nimport registerComponent, {\n CanvasComponentProps,\n ComponentMeta,\n} from \"@daouy/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@daouy/host/registerGlobalContext\";\nimport { useDaouyQueryData } from \"@daouy/query\";\nimport React from \"react\";\n\nconst defaultHost = \"https://studio.quocuy.cloud\";\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 = useDaouyQueryData(\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 } = useDaouyQueryData(\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 = useDaouyCanvasContext();\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 = \"@daouypkgs/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: \"Daouy 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 \"@daouy/host/registerComponent\";\nimport registerGlobalContext from \"@daouy/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","useDaouyQueryData","JSON","stringify","_asyncToGenerator","_regenerator","m","_callee","pathname","url","w","_context","n","Error","encodeURIComponent","fetch","method","v","json","a","fields","_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","i","direction","search","length","join","_useDaouyQueryData","_callee2","_context2","records","isLoading","map","index","key","repeatedElement","AirtableCredentialsProvider","_ref6","dataSource","maybeHost","inCanvas","useDaouyCanvasContext","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,6BAA6B;AAQjD,IAAMC,kBAAkB,gBAAGC,KAAK,CAACC,aAAa,CAC5CC,SAAS,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e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@daouy/host"),r=e(require("@daouy/host/registerComponent")),o=e(require("@daouy/host/registerGlobalContext")),n=require("@daouy/query"),a=e(require("react"));function i(e,t,r,o,n,a,i){try{var l=e[a](i),s=l.value}catch(e){return void r(e)}l.done?t(s):Promise.resolve(s).then(o,n)}function l(e){return function(){var t=this,r=arguments;return new Promise((function(o,n){var a=e.apply(t,r);function l(e){i(a,o,n,l,s,"next",e)}function s(e){i(a,o,n,l,s,"throw",e)}l(void 0)}))}}function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)({}).hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(null,arguments)}function c(){var e,t,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",n=r.toStringTag||"@@toStringTag";function a(r,o,n,a){var s=Object.create((o&&o.prototype instanceof l?o:l).prototype);return d(s,"_invoke",function(r,o,n){var a,l,s,c=0,d=n||[],u=!1,p={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,r){return a=t,l=0,s=e,p.n=r,i}};function f(r,o){for(l=r,s=o,t=0;!u&&c&&!n&&t<d.length;t++){var n,a=d[t],f=p.p,m=a[2];r>3?(n=m===o)&&(s=a[(l=a[4])?5:(l=3,3)],a[4]=a[5]=e):a[0]<=f&&((n=r<2&&f<a[1])?(l=0,p.v=o,p.n=a[1]):f<m&&(n=r<3||a[0]>o||o>m)&&(a[4]=r,a[5]=o,p.n=m,l=0))}if(n||r>1)return i;throw u=!0,o}return function(n,d,m){if(c>1)throw TypeError("Generator is already running");for(u&&1===d&&f(d,m),l=d,s=m;(t=l<2?e:s)||!u;){a||(l?l<3?(l>1&&(p.n=-1),f(l,s)):p.n=s:p.v=s);try{if(c=2,a){if(l||(n="next"),t=a[n]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,l<2&&(l=0)}else 1===l&&(t=a.return)&&t.call(a),l<2&&(s=TypeError("The iterator does not provide a '"+n+"' method"),l=1);a=e}else if((t=(u=p.n<0)?s:r.call(o,p))!==i)break}catch(t){a=e,l=1,s=t}finally{c=1}}return{value:t,done:u}}}(r,n,a),!0),s}var i={};function l(){}function s(){}function u(){}t=Object.getPrototypeOf;var p=[][o]?t(t([][o]())):(d(t={},o,(function(){return this})),t),f=u.prototype=l.prototype=Object.create(p);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,d(e,n,"GeneratorFunction")),e.prototype=Object.create(f),e}return s.prototype=u,d(f,"constructor",u),d(u,"constructor",s),s.displayName="GeneratorFunction",d(u,n,"GeneratorFunction"),d(f),d(f,n,"Generator"),d(f,o,(function(){return this})),d(f,"toString",(function(){return"[object Generator]"})),(c=function(){return{w:a,m:m}})()}function d(e,t,r,o){var n=Object.defineProperty;try{n({},"",{})}catch(e){n=0}(d=function(e,t,r,o){function a(t,r){d(e,t,(function(e){return this._invoke(t,r,e)}))}t?n?n(e,t,{value:r,enumerable:!o,configurable:!o,writable:!o}):e[t]=r:(a("next",0),a("throw",1),a("return",2))})(e,t,r,o)}var u=["table","children"],p="https://studio.quocuy.cloud",f=a.createContext(void 0);function m(e){var r,o=e.table,i=e.record,s=e.children,d=a.useContext(f),u=d&&d.id,m=d&&d.base,h=d&&d.host||p,y=n.useDaouyQueryData(JSON.stringify(["AirtableRecord",h,m,o,i,u]),l(c().m((function e(){var t;return c().w((function(e){for(;;)switch(e.n){case 0:if(m&&u){e.n=1;break}throw new Error("Missing Data Source. Please select a Data Source from the Airtable Credentials Provider");case 1:if(o){e.n=2;break}throw new Error("AirtableRecord is missing the table name");case 2:if(i){e.n=3;break}throw new Error("AirtableRecord is missing the record ID");case 3:return t=h+"/api/v1/server-data/query?pathname="+encodeURIComponent("/"+m+"/"+o+"/"+i)+"&dataSourceId="+u,e.n=4,fetch(t,{method:"GET"});case 4:return e.n=5,e.v.json();case 5:return e.a(2,e.v.fields)}}),e)}))));return"error"in y?a.createElement("p",null,"Error: ",null==(r=y.error)?void 0:r.message):"data"in y?a.createElement(t.DataProvider,{name:b,data:y.data},s):a.createElement("p",null,"Loading...")}var b="__airtableRecord";function h(e){var r,o=e.className,n=e.field,i=e.style,l=e.setControlContextData,s=t.useSelector(b);return null==l||l(s),a.createElement("div",{className:o,style:i},s?(r=s[n||Object.keys(s)[0]])&&"object"==typeof r?"Attachment "+r[0].filename:r:"Error: Must provide a record to AirtableRecordField")}function y(e){var r=e.table,o=e.children,i=function(e,t){if(null==e)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(-1!==t.indexOf(o))continue;r[o]=e[o]}return r}(e,u),s=a.useContext(f),d=s&&s.id,m=s&&s.base,h=s&&s.host||p,y=[];i.fields&&i.fields.forEach((function(e){return y.push(encodeURIComponent("fields[]")+"="+encodeURIComponent(""+e))})),["filterByFormula","maxRecords","pageSize","view"].forEach((function(e){i[e]&&y.push(encodeURIComponent(""+e)+"="+encodeURIComponent(""+i[e]))})),i.sort&&i.sort.forEach((function(e,t){y.push(encodeURIComponent("sort["+t+"][field]")+"="+encodeURIComponent(""+e.field)),e.direction&&y.push(encodeURIComponent("sort["+t+"][direction]")+"="+encodeURIComponent(""+e.direction))}));var v=0===y.length?"":"?"+y.join("&"),g=n.useDaouyQueryData(JSON.stringify(["AirtableCollection",h,m,r,v,d]),l(c().m((function e(){var t;return c().w((function(e){for(;;)switch(e.n){case 0:if(m&&d){e.n=1;break}throw new Error("Missing Data Source. Please select a Data Source from the Airtable Credentials Provider");case 1:if(r){e.n=2;break}throw new Error("AirtableCollection is missing the table name");case 2:return t=h+"/api/v1/server-data/query?pathname="+encodeURIComponent("/"+m+"/"+r+v)+"&dataSourceId="+d,e.n=3,fetch(t,{method:"GET"});case 3:return e.n=4,e.v.json();case 4:return e.a(2,e.v.records)}}),e)})))),C=g.data,A=g.error,w=g.isLoading;return A?a.createElement("p",null,"Error: ",A.message):w?a.createElement("p",null,"Loading..."):a.createElement(a.Fragment,null,(null!=C?C:[]).map((function(e,r){return a.createElement(t.DataProvider,{key:e.id,name:b,data:e.fields},t.repeatedElement(r,o))})))}function v(e){var r=e.dataSource,o=e.host,n=e.children;return!t.useDaouyCanvasContext()||r&&r.id&&r.base?a.createElement(f.Provider,{value:s({},r,{host:o||p})},n):a.createElement("p",null,"Error: Missing Data Source. Please select a Data Source from the Airtable Credentials Provider")}var g="@daouypkgs/airtable",C={name:"hostless-airtable-record",displayName:"Airtable Record",importPath:g,importName:"AirtableRecord",providesData:!0,props:{children:{type:"slot",defaultValue:{type:"component",name:"hostless-airtable-record-field"}},table:{type:"string",displayName:"Table Name",description:"The Airtable table name or ID"},record:{type:"string",displayName:"Record",description:"The table record ID"}}};function A(e,t){e?e.registerComponent(m,null!=t?t:C):r(m,null!=t?t:C)}var w={name:"hostless-airtable-record-field",displayName:"Airtable Record Field",importPath:g,importName:"AirtableRecordField",props:{field:{type:"choice",displayName:"Field Name",defaultValueHint:"The first field",options:function(e,t){return t?Object.keys(t):["Data unavailable"]}}}};function R(e,t){e?e.registerComponent(h,null!=t?t:w):r(h,null!=t?t:w)}var x={name:"hostless-airtable-collection",displayName:"Airtable Collection",importPath:g,importName:"AirtableCollection",providesData:!0,props:{children:{type:"slot",isRepeated:!0,defaultValue:{type:"component",name:"hostless-airtable-record-field"}},table:{type:"string",displayName:"Table Name",description:"The Airtable table name or ID"},fields:{type:"object",displayName:"Fields",description:"List of strings containing the fields to be included"},maxRecords:{type:"number",displayName:"Max Records",description:"The maximum total number of records that will be returned",defaultValueHint:100,max:100,min:1},view:{type:"string",displayName:"View",description:"The name or ID of a view in the table. If set, only records from that view will be returned"},sort:{type:"object",displayName:"Sort",description:'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"'},filterByFormula:{type:"string",displayName:"Filter by Formula",description:"An Airtable formula used to filter records"}}};function E(e,t){e?e.registerComponent(y,null!=t?t:x):r(y,null!=t?t:x)}var N={name:"hostless-airtable-credentials-provider",displayName:"Airtable Credentials Provider",importPath:g,importName:"AirtableCredentialsProvider",props:{dataSource:{type:"dataSource",dataSource:"airtable",displayName:"Data Source",description:"The Airtable Data Source to use"},host:{type:"string",displayName:"Host",description:"Daouy Server-Data URL",defaultValueHint:p}}};function P(e,t){e?e.registerGlobalContext(v,null!=t?t:N):o(v,null!=t?t:N)}exports.AirtableCollection=y,exports.AirtableCredentialsProvider=v,exports.AirtableRecord=m,exports.AirtableRecordField=h,exports.airtableCollectionMeta=x,exports.airtableCredentialsProviderMeta=N,exports.airtableRecordFieldMeta=w,exports.airtableRecordMeta=C,exports.registerAirtableCollection=E,exports.registerAirtableCredentialsProvider=P,exports.registerAirtableRecord=A,exports.registerAirtableRecordField=R,exports.registerAll=function(e){E(e),P(e),A(e),R(e)};
|
|
2
|
+
//# sourceMappingURL=airtable.cjs.production.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"airtable.cjs.production.min.js","sources":["../src/RecordData.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n repeatedElement,\n useDaouyCanvasContext,\n useSelector,\n} from \"@daouy/host\";\nimport registerComponent, {\n CanvasComponentProps,\n ComponentMeta,\n} from \"@daouy/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@daouy/host/registerGlobalContext\";\nimport { useDaouyQueryData } from \"@daouy/query\";\nimport React from \"react\";\n\nconst defaultHost = \"https://studio.quocuy.cloud\";\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 = useDaouyQueryData(\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 } = useDaouyQueryData(\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 = useDaouyCanvasContext();\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 = \"@daouypkgs/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: \"Daouy 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 \"@daouy/host/registerComponent\";\nimport registerGlobalContext from \"@daouy/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","useDaouyQueryData","JSON","stringify","_asyncToGenerator","_regenerator","m","_callee","url","w","_context","n","Error","encodeURIComponent","fetch","method","v","json","a","fields","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","i","direction","search","length","join","_useDaouyQueryData","_callee2","_context2","records","isLoading","map","index","key","repeatedElement","AirtableCredentialsProvider","_ref6","dataSource","maybeHost","useDaouyCanvasContext","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":"62FAgBMA,EAAc,8BAQdC,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,oBACXC,KAAKC,UAAU,CAAC,iBAAkBJ,EAAMD,EAAMP,EAAOC,EAAQI,IAAcQ,EAAAC,IAAAC,GAC3E,SAAAC,IAAA,IAAAC,EAAA,OAAAH,IAAAI,YAAAC,GAAA,cAAAA,EAAAC,GAAA,OAAA,GACOb,GAASF,GAAYc,EAAAC,IAAA,MAAA,MAClB,IAAIC,MACR,2FACD,OAAA,GAEErB,GAAKmB,EAAAC,IAAA,MAAA,MACF,IAAIC,MAAM,4CAA2C,OAAA,GAExDpB,GAAMkB,EAAAC,IAAA,MAAA,MACH,IAAIC,MAAM,2CAA0C,OAK9B,OAFxBJ,EAAST,wCAA0Cc,uBADpCf,MAAQP,MAASC,oBAGpBI,EAAYc,EAAAC,IACTG,MAAMN,EAAK,CAAEO,OAAQ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bM,YAAa,yDAKHkB,EACdhB,EACAiB,GAEIjB,EACFA,EAAOE,kBACL7C,QACA4D,EAAAA,EAAgCR,GAGlCP,EACE7C,QACA4D,EAAAA,EAAgCR,OAKzBS,EAAuF,CAClG1E,KAAM,yCACNgD,YAAa,gCACbC,WAAYH,EACZI,WAAY,8BACZnC,MAAO,CACLyB,WAAY,CACVY,KAAM,aACNZ,WAAY,WACZQ,YAAa,cACbM,YAAa,mCAEf9E,KAAM,CACJ4E,KAAM,SACNJ,YAAa,OACbM,YAAa,wBACbM,iBAAkBpG,cAKRmH,EACdnB,EACAoB,GAEIpB,EACFA,EAAOqB,sBACLvC,QACAsC,EAAAA,EAAyCF,GAG3CG,EACEvC,QACAsC,EAAAA,EAAyCF,8bCjbnBlB,GAI1BgB,EAA2BhB,GAC3BmB,EAAoCnB,GACpCD,EAAuBC,GACvBO,EAA4BP"}
|
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
import { DataProvider, useSelector, repeatedElement, useDaouyCanvasContext } from '@daouy/host';
|
|
2
|
+
import registerComponent from '@daouy/host/registerComponent';
|
|
3
|
+
import registerGlobalContext from '@daouy/host/registerGlobalContext';
|
|
4
|
+
import { useDaouyQueryData } from '@daouy/query';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
8
|
+
try {
|
|
9
|
+
var i = n[a](c),
|
|
10
|
+
u = i.value;
|
|
11
|
+
} catch (n) {
|
|
12
|
+
return void e(n);
|
|
13
|
+
}
|
|
14
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
15
|
+
}
|
|
16
|
+
function _asyncToGenerator(n) {
|
|
17
|
+
return function () {
|
|
18
|
+
var t = this,
|
|
19
|
+
e = arguments;
|
|
20
|
+
return new Promise(function (r, o) {
|
|
21
|
+
var a = n.apply(t, e);
|
|
22
|
+
function _next(n) {
|
|
23
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
24
|
+
}
|
|
25
|
+
function _throw(n) {
|
|
26
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
27
|
+
}
|
|
28
|
+
_next(void 0);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function _extends() {
|
|
33
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
34
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
35
|
+
var t = arguments[e];
|
|
36
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
37
|
+
}
|
|
38
|
+
return n;
|
|
39
|
+
}, _extends.apply(null, arguments);
|
|
40
|
+
}
|
|
41
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
42
|
+
if (null == r) return {};
|
|
43
|
+
var t = {};
|
|
44
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
45
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
46
|
+
t[n] = r[n];
|
|
47
|
+
}
|
|
48
|
+
return t;
|
|
49
|
+
}
|
|
50
|
+
function _regenerator() {
|
|
51
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
52
|
+
var e,
|
|
53
|
+
t,
|
|
54
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
55
|
+
n = r.iterator || "@@iterator",
|
|
56
|
+
o = r.toStringTag || "@@toStringTag";
|
|
57
|
+
function i(r, n, o, i) {
|
|
58
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
59
|
+
u = Object.create(c.prototype);
|
|
60
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
61
|
+
var i,
|
|
62
|
+
c,
|
|
63
|
+
u,
|
|
64
|
+
f = 0,
|
|
65
|
+
p = o || [],
|
|
66
|
+
y = !1,
|
|
67
|
+
G = {
|
|
68
|
+
p: 0,
|
|
69
|
+
n: 0,
|
|
70
|
+
v: e,
|
|
71
|
+
a: d,
|
|
72
|
+
f: d.bind(e, 4),
|
|
73
|
+
d: function (t, r) {
|
|
74
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function d(r, n) {
|
|
78
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
79
|
+
var o,
|
|
80
|
+
i = p[t],
|
|
81
|
+
d = G.p,
|
|
82
|
+
l = i[2];
|
|
83
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
84
|
+
}
|
|
85
|
+
if (o || r > 1) return a;
|
|
86
|
+
throw y = !0, n;
|
|
87
|
+
}
|
|
88
|
+
return function (o, p, l) {
|
|
89
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
90
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
91
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
92
|
+
try {
|
|
93
|
+
if (f = 2, i) {
|
|
94
|
+
if (c || (o = "next"), t = i[o]) {
|
|
95
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
96
|
+
if (!t.done) return t;
|
|
97
|
+
u = t.value, c < 2 && (c = 0);
|
|
98
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
99
|
+
i = e;
|
|
100
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
101
|
+
} catch (t) {
|
|
102
|
+
i = e, c = 1, u = t;
|
|
103
|
+
} finally {
|
|
104
|
+
f = 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
value: t,
|
|
109
|
+
done: y
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
}(r, o, i), !0), u;
|
|
113
|
+
}
|
|
114
|
+
var a = {};
|
|
115
|
+
function Generator() {}
|
|
116
|
+
function GeneratorFunction() {}
|
|
117
|
+
function GeneratorFunctionPrototype() {}
|
|
118
|
+
t = Object.getPrototypeOf;
|
|
119
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
120
|
+
return this;
|
|
121
|
+
}), t),
|
|
122
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
123
|
+
function f(e) {
|
|
124
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
125
|
+
}
|
|
126
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
127
|
+
return this;
|
|
128
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
129
|
+
return "[object Generator]";
|
|
130
|
+
}), (_regenerator = function () {
|
|
131
|
+
return {
|
|
132
|
+
w: i,
|
|
133
|
+
m: f
|
|
134
|
+
};
|
|
135
|
+
})();
|
|
136
|
+
}
|
|
137
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
138
|
+
var i = Object.defineProperty;
|
|
139
|
+
try {
|
|
140
|
+
i({}, "", {});
|
|
141
|
+
} catch (e) {
|
|
142
|
+
i = 0;
|
|
143
|
+
}
|
|
144
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
145
|
+
function o(r, n) {
|
|
146
|
+
_regeneratorDefine(e, r, function (e) {
|
|
147
|
+
return this._invoke(r, n, e);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
r ? i ? i(e, r, {
|
|
151
|
+
value: n,
|
|
152
|
+
enumerable: !t,
|
|
153
|
+
configurable: !t,
|
|
154
|
+
writable: !t
|
|
155
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
156
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
var _excluded = ["table", "children"];
|
|
160
|
+
var defaultHost = "https://studio.quocuy.cloud";
|
|
161
|
+
var CredentialsContext = /*#__PURE__*/React.createContext(undefined);
|
|
162
|
+
function AirtableRecord(_ref) {
|
|
163
|
+
var table = _ref.table,
|
|
164
|
+
record = _ref.record,
|
|
165
|
+
children = _ref.children;
|
|
166
|
+
var credentialsContext = React.useContext(CredentialsContext);
|
|
167
|
+
var dataSourceId = credentialsContext && credentialsContext.id;
|
|
168
|
+
var base = credentialsContext && credentialsContext.base;
|
|
169
|
+
var host = credentialsContext && credentialsContext.host || defaultHost;
|
|
170
|
+
var data = useDaouyQueryData(JSON.stringify(["AirtableRecord", host, base, table, record, dataSourceId]), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
171
|
+
var pathname, url;
|
|
172
|
+
return _regenerator().w(function (_context) {
|
|
173
|
+
while (1) switch (_context.n) {
|
|
174
|
+
case 0:
|
|
175
|
+
if (!(!base || !dataSourceId)) {
|
|
176
|
+
_context.n = 1;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
throw new Error("Missing Data Source. Please select a Data Source from the Airtable Credentials Provider");
|
|
180
|
+
case 1:
|
|
181
|
+
if (table) {
|
|
182
|
+
_context.n = 2;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
throw new Error("AirtableRecord is missing the table name");
|
|
186
|
+
case 2:
|
|
187
|
+
if (record) {
|
|
188
|
+
_context.n = 3;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
throw new Error("AirtableRecord is missing the record ID");
|
|
192
|
+
case 3:
|
|
193
|
+
pathname = "/" + base + "/" + table + "/" + record;
|
|
194
|
+
url = host + "/api/v1/server-data/query?pathname=" + encodeURIComponent(pathname) + "&dataSourceId=" + dataSourceId;
|
|
195
|
+
_context.n = 4;
|
|
196
|
+
return fetch(url, {
|
|
197
|
+
method: "GET"
|
|
198
|
+
});
|
|
199
|
+
case 4:
|
|
200
|
+
_context.n = 5;
|
|
201
|
+
return _context.v.json();
|
|
202
|
+
case 5:
|
|
203
|
+
return _context.a(2, _context.v.fields);
|
|
204
|
+
}
|
|
205
|
+
}, _callee);
|
|
206
|
+
})));
|
|
207
|
+
if ("error" in data) {
|
|
208
|
+
var _data$error;
|
|
209
|
+
return React.createElement("p", null, "Error: ", (_data$error = data.error) == null ? void 0 : _data$error.message);
|
|
210
|
+
}
|
|
211
|
+
if (!("data" in data)) {
|
|
212
|
+
return React.createElement("p", null, "Loading...");
|
|
213
|
+
}
|
|
214
|
+
return React.createElement(DataProvider, {
|
|
215
|
+
name: contextKey,
|
|
216
|
+
data: data.data
|
|
217
|
+
}, children);
|
|
218
|
+
}
|
|
219
|
+
var contextKey = "__airtableRecord";
|
|
220
|
+
function useRecord() {
|
|
221
|
+
return useSelector(contextKey);
|
|
222
|
+
}
|
|
223
|
+
function AirtableRecordField(_ref3) {
|
|
224
|
+
var className = _ref3.className,
|
|
225
|
+
field = _ref3.field,
|
|
226
|
+
style = _ref3.style,
|
|
227
|
+
setControlContextData = _ref3.setControlContextData;
|
|
228
|
+
var record = useRecord();
|
|
229
|
+
setControlContextData == null || setControlContextData(record);
|
|
230
|
+
return React.createElement("div", {
|
|
231
|
+
className: className,
|
|
232
|
+
style: style
|
|
233
|
+
}, record ? function () {
|
|
234
|
+
var val = record[field || Object.keys(record)[0]];
|
|
235
|
+
if (val && typeof val === "object") {
|
|
236
|
+
return "Attachment " + val[0].filename;
|
|
237
|
+
}
|
|
238
|
+
return val;
|
|
239
|
+
}() : "Error: Must provide a record to AirtableRecordField");
|
|
240
|
+
}
|
|
241
|
+
function AirtableCollection(_ref4) {
|
|
242
|
+
var table = _ref4.table,
|
|
243
|
+
children = _ref4.children,
|
|
244
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded);
|
|
245
|
+
var credentialsContext = React.useContext(CredentialsContext);
|
|
246
|
+
var dataSourceId = credentialsContext && credentialsContext.id;
|
|
247
|
+
var base = credentialsContext && credentialsContext.base;
|
|
248
|
+
var host = credentialsContext && credentialsContext.host || defaultHost;
|
|
249
|
+
var searchArray = [];
|
|
250
|
+
if (props.fields) {
|
|
251
|
+
props.fields.forEach(function (f) {
|
|
252
|
+
return searchArray.push(encodeURIComponent("fields[]") + "=" + encodeURIComponent("" + f));
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
["filterByFormula", "maxRecords", "pageSize", "view"].forEach(function (prop) {
|
|
256
|
+
if (props[prop]) {
|
|
257
|
+
searchArray.push(encodeURIComponent("" + prop) + "=" + encodeURIComponent("" + props[prop]));
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
if (props.sort) {
|
|
261
|
+
props.sort.forEach(function (v, i) {
|
|
262
|
+
searchArray.push(encodeURIComponent("sort[" + i + "][field]") + "=" + encodeURIComponent("" + v.field));
|
|
263
|
+
if (v.direction) {
|
|
264
|
+
searchArray.push(encodeURIComponent("sort[" + i + "][direction]") + "=" + encodeURIComponent("" + v.direction));
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
var search = searchArray.length === 0 ? "" : "?" + searchArray.join("&");
|
|
269
|
+
var _useDaouyQueryData = useDaouyQueryData(JSON.stringify(["AirtableCollection", host, base, table, search, dataSourceId]), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
270
|
+
var pathname, url;
|
|
271
|
+
return _regenerator().w(function (_context2) {
|
|
272
|
+
while (1) switch (_context2.n) {
|
|
273
|
+
case 0:
|
|
274
|
+
if (!(!base || !dataSourceId)) {
|
|
275
|
+
_context2.n = 1;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
throw new Error("Missing Data Source. Please select a Data Source from the Airtable Credentials Provider");
|
|
279
|
+
case 1:
|
|
280
|
+
if (table) {
|
|
281
|
+
_context2.n = 2;
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
throw new Error("AirtableCollection is missing the table name");
|
|
285
|
+
case 2:
|
|
286
|
+
pathname = "/" + base + "/" + table + search;
|
|
287
|
+
url = host + "/api/v1/server-data/query?pathname=" + encodeURIComponent(pathname) + "&dataSourceId=" + dataSourceId;
|
|
288
|
+
_context2.n = 3;
|
|
289
|
+
return fetch(url, {
|
|
290
|
+
method: "GET"
|
|
291
|
+
});
|
|
292
|
+
case 3:
|
|
293
|
+
_context2.n = 4;
|
|
294
|
+
return _context2.v.json();
|
|
295
|
+
case 4:
|
|
296
|
+
return _context2.a(2, _context2.v.records);
|
|
297
|
+
}
|
|
298
|
+
}, _callee2);
|
|
299
|
+
}))),
|
|
300
|
+
data = _useDaouyQueryData.data,
|
|
301
|
+
error = _useDaouyQueryData.error,
|
|
302
|
+
isLoading = _useDaouyQueryData.isLoading;
|
|
303
|
+
if (error) {
|
|
304
|
+
return React.createElement("p", null, "Error: ", error.message);
|
|
305
|
+
}
|
|
306
|
+
if (isLoading) {
|
|
307
|
+
return React.createElement("p", null, "Loading...");
|
|
308
|
+
}
|
|
309
|
+
return React.createElement(React.Fragment, null, (data != null ? data : []).map(function (record, index) {
|
|
310
|
+
return React.createElement(DataProvider, {
|
|
311
|
+
key: record.id,
|
|
312
|
+
name: contextKey,
|
|
313
|
+
data: record.fields
|
|
314
|
+
}, repeatedElement(index, children));
|
|
315
|
+
}));
|
|
316
|
+
}
|
|
317
|
+
function AirtableCredentialsProvider(_ref6) {
|
|
318
|
+
var dataSource = _ref6.dataSource,
|
|
319
|
+
maybeHost = _ref6.host,
|
|
320
|
+
children = _ref6.children;
|
|
321
|
+
var inCanvas = useDaouyCanvasContext();
|
|
322
|
+
if (inCanvas && (!dataSource || !dataSource.id || !dataSource.base)) {
|
|
323
|
+
return React.createElement("p", null, "Error: Missing Data Source. Please select a Data Source from the Airtable Credentials Provider");
|
|
324
|
+
}
|
|
325
|
+
var host = maybeHost || defaultHost;
|
|
326
|
+
return React.createElement(CredentialsContext.Provider, {
|
|
327
|
+
value: _extends({}, dataSource, {
|
|
328
|
+
host: host
|
|
329
|
+
})
|
|
330
|
+
}, children);
|
|
331
|
+
}
|
|
332
|
+
var thisModule = "@daouypkgs/airtable";
|
|
333
|
+
var airtableRecordMeta = {
|
|
334
|
+
name: "hostless-airtable-record",
|
|
335
|
+
displayName: "Airtable Record",
|
|
336
|
+
importPath: thisModule,
|
|
337
|
+
importName: "AirtableRecord",
|
|
338
|
+
providesData: true,
|
|
339
|
+
props: {
|
|
340
|
+
children: {
|
|
341
|
+
type: "slot",
|
|
342
|
+
defaultValue: {
|
|
343
|
+
type: "component",
|
|
344
|
+
name: "hostless-airtable-record-field"
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
table: {
|
|
348
|
+
type: "string",
|
|
349
|
+
displayName: "Table Name",
|
|
350
|
+
description: "The Airtable table name or ID"
|
|
351
|
+
},
|
|
352
|
+
record: {
|
|
353
|
+
type: "string",
|
|
354
|
+
displayName: "Record",
|
|
355
|
+
description: "The table record ID"
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
function registerAirtableRecord(loader, customAirtableRecordMeta) {
|
|
360
|
+
if (loader) {
|
|
361
|
+
loader.registerComponent(AirtableRecord, customAirtableRecordMeta != null ? customAirtableRecordMeta : airtableRecordMeta);
|
|
362
|
+
} else {
|
|
363
|
+
registerComponent(AirtableRecord, customAirtableRecordMeta != null ? customAirtableRecordMeta : airtableRecordMeta);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
var airtableRecordFieldMeta = {
|
|
367
|
+
name: "hostless-airtable-record-field",
|
|
368
|
+
displayName: "Airtable Record Field",
|
|
369
|
+
importPath: thisModule,
|
|
370
|
+
importName: "AirtableRecordField",
|
|
371
|
+
props: {
|
|
372
|
+
field: {
|
|
373
|
+
type: "choice",
|
|
374
|
+
displayName: "Field Name",
|
|
375
|
+
defaultValueHint: "The first field",
|
|
376
|
+
options: function options(_props, data) {
|
|
377
|
+
return data ? Object.keys(data) : ["Data unavailable"];
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
function registerAirtableRecordField(loader, customAirtableRecordFieldMeta) {
|
|
383
|
+
if (loader) {
|
|
384
|
+
loader.registerComponent(AirtableRecordField, customAirtableRecordFieldMeta != null ? customAirtableRecordFieldMeta : airtableRecordFieldMeta);
|
|
385
|
+
} else {
|
|
386
|
+
registerComponent(AirtableRecordField, customAirtableRecordFieldMeta != null ? customAirtableRecordFieldMeta : airtableRecordFieldMeta);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
var airtableCollectionMeta = {
|
|
390
|
+
name: "hostless-airtable-collection",
|
|
391
|
+
displayName: "Airtable Collection",
|
|
392
|
+
importPath: thisModule,
|
|
393
|
+
importName: "AirtableCollection",
|
|
394
|
+
providesData: true,
|
|
395
|
+
props: {
|
|
396
|
+
children: {
|
|
397
|
+
type: "slot",
|
|
398
|
+
isRepeated: true,
|
|
399
|
+
defaultValue: {
|
|
400
|
+
type: "component",
|
|
401
|
+
name: "hostless-airtable-record-field"
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
table: {
|
|
405
|
+
type: "string",
|
|
406
|
+
displayName: "Table Name",
|
|
407
|
+
description: "The Airtable table name or ID"
|
|
408
|
+
},
|
|
409
|
+
fields: {
|
|
410
|
+
type: "object",
|
|
411
|
+
displayName: "Fields",
|
|
412
|
+
description: "List of strings containing the fields to be included"
|
|
413
|
+
},
|
|
414
|
+
maxRecords: {
|
|
415
|
+
type: "number",
|
|
416
|
+
displayName: "Max Records",
|
|
417
|
+
description: "The maximum total number of records that will be returned",
|
|
418
|
+
defaultValueHint: 100,
|
|
419
|
+
max: 100,
|
|
420
|
+
min: 1
|
|
421
|
+
},
|
|
422
|
+
view: {
|
|
423
|
+
type: "string",
|
|
424
|
+
displayName: "View",
|
|
425
|
+
description: "The name or ID of a view in the table. If set, only records from that view will be returned"
|
|
426
|
+
},
|
|
427
|
+
sort: {
|
|
428
|
+
type: "object",
|
|
429
|
+
displayName: "Sort",
|
|
430
|
+
description: '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"'
|
|
431
|
+
},
|
|
432
|
+
filterByFormula: {
|
|
433
|
+
type: "string",
|
|
434
|
+
displayName: "Filter by Formula",
|
|
435
|
+
description: "An Airtable formula used to filter records"
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
function registerAirtableCollection(loader, customAirtableCollectionMeta) {
|
|
440
|
+
if (loader) {
|
|
441
|
+
loader.registerComponent(AirtableCollection, customAirtableCollectionMeta != null ? customAirtableCollectionMeta : airtableCollectionMeta);
|
|
442
|
+
} else {
|
|
443
|
+
registerComponent(AirtableCollection, customAirtableCollectionMeta != null ? customAirtableCollectionMeta : airtableCollectionMeta);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
var airtableCredentialsProviderMeta = {
|
|
447
|
+
name: "hostless-airtable-credentials-provider",
|
|
448
|
+
displayName: "Airtable Credentials Provider",
|
|
449
|
+
importPath: thisModule,
|
|
450
|
+
importName: "AirtableCredentialsProvider",
|
|
451
|
+
props: {
|
|
452
|
+
dataSource: {
|
|
453
|
+
type: "dataSource",
|
|
454
|
+
dataSource: "airtable",
|
|
455
|
+
displayName: "Data Source",
|
|
456
|
+
description: "The Airtable Data Source to use"
|
|
457
|
+
},
|
|
458
|
+
host: {
|
|
459
|
+
type: "string",
|
|
460
|
+
displayName: "Host",
|
|
461
|
+
description: "Daouy Server-Data URL",
|
|
462
|
+
defaultValueHint: defaultHost
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
function registerAirtableCredentialsProvider(loader, customAirtableCredentialsProviderMeta) {
|
|
467
|
+
if (loader) {
|
|
468
|
+
loader.registerGlobalContext(AirtableCredentialsProvider, customAirtableCredentialsProviderMeta != null ? customAirtableCredentialsProviderMeta : airtableCredentialsProviderMeta);
|
|
469
|
+
} else {
|
|
470
|
+
registerGlobalContext(AirtableCredentialsProvider, customAirtableCredentialsProviderMeta != null ? customAirtableCredentialsProviderMeta : airtableCredentialsProviderMeta);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function registerAll(loader) {
|
|
475
|
+
registerAirtableCollection(loader);
|
|
476
|
+
registerAirtableCredentialsProvider(loader);
|
|
477
|
+
registerAirtableRecord(loader);
|
|
478
|
+
registerAirtableRecordField(loader);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export { AirtableCollection, AirtableCredentialsProvider, AirtableRecord, AirtableRecordField, airtableCollectionMeta, airtableCredentialsProviderMeta, airtableRecordFieldMeta, airtableRecordMeta, registerAirtableCollection, registerAirtableCredentialsProvider, registerAirtableRecord, registerAirtableRecordField, registerAll };
|
|
482
|
+
//# sourceMappingURL=airtable.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"airtable.esm.js","sources":["../src/RecordData.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n repeatedElement,\n useDaouyCanvasContext,\n useSelector,\n} from \"@daouy/host\";\nimport registerComponent, {\n CanvasComponentProps,\n ComponentMeta,\n} from \"@daouy/host/registerComponent\";\nimport registerGlobalContext, {\n GlobalContextMeta,\n} from \"@daouy/host/registerGlobalContext\";\nimport { useDaouyQueryData } from \"@daouy/query\";\nimport React from \"react\";\n\nconst defaultHost = \"https://studio.quocuy.cloud\";\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 = useDaouyQueryData(\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 } = useDaouyQueryData(\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 = useDaouyCanvasContext();\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 = \"@daouypkgs/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: \"Daouy 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 \"@daouy/host/registerComponent\";\nimport registerGlobalContext from \"@daouy/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","useDaouyQueryData","JSON","stringify","_asyncToGenerator","_regenerator","m","_callee","pathname","url","w","_context","n","Error","encodeURIComponent","fetch","method","v","json","a","fields","_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","i","direction","search","length","join","_useDaouyQueryData","_callee2","_context2","records","isLoading","map","index","key","repeatedElement","AirtableCredentialsProvider","_ref6","dataSource","maybeHost","inCanvas","useDaouyCanvasContext","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,6BAA6B;AAQjD,IAAMC,kBAAkB,gBAAGC,KAAK,CAACC,aAAa,CAC5CC,SAAS,CACV;SAWeC,cAAcA,CAAAC,IAAA;MAC5BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,MAAM,GAAAF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C,kBAAkB,EAClB6D,4BAA4B,WAA5BA,4BAA4B,GAAIR,sBAAsB,CACvD;GACF,MAAM;IACLP,iBAAiB,CACf9C,kBAAkB,EAClB6D,4BAA4B,WAA5BA,4BAA4B,GAAIR,sBAAsB,CACvD;;AAEL;IAEaS,+BAA+B,GAAwD;EAClG5E,IAAI,EAAE,wCAAwC;EAC9CkD,WAAW,EAAE,+BAA+B;EAC5CC,UAAU,EAAEH,UAAU;EACtBI,UAAU,EAAE,6BAA6B;EACzCpC,KAAK,EAAE;IACLyB,UAAU,EAAE;MACVa,IAAI,EAAE,YAAY;MAClBb,UAAU,EAAE,UAAU;MACtBS,WAAW,EAAE,aAAa;MAC1BM,WAAW,EAAE;KACd;IACDlF,IAAI,EAAE;MACJgF,IAAI,EAAE,QAAQ;MACdJ,WAAW,EAAE,MAAM;MACnBM,WAAW,EAAE,uBAAuB;MACpCM,gBAAgB,EAAEvG;;;;SAKRsH,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/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./RecordData";
|
|
2
|
+
import registerComponent from "@daouy/host/registerComponent";
|
|
3
|
+
import registerGlobalContext from "@daouy/host/registerGlobalContext";
|
|
4
|
+
export declare function registerAll(loader?: {
|
|
5
|
+
registerComponent: typeof registerComponent;
|
|
6
|
+
registerGlobalContext: typeof registerGlobalContext;
|
|
7
|
+
}): void;
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@daouypkgs/airtable",
|
|
3
|
+
"version": "0.0.249",
|
|
4
|
+
"description": "Daouy registration call for the HTML5 video element",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/airtable.esm.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"size-limit": [
|
|
12
|
+
{
|
|
13
|
+
"path": "dist/airtable.cjs.production.min.js",
|
|
14
|
+
"limit": "20 KB"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "dist/airtable.esm.js",
|
|
18
|
+
"limit": "20 KB"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsdx build",
|
|
23
|
+
"start": "tsdx watch",
|
|
24
|
+
"test": "TEST_CWD=`pwd` yarn --cwd=../.. test --passWithNoTests",
|
|
25
|
+
"lint": "tsdx lint",
|
|
26
|
+
"prepublishOnly": "npm run build",
|
|
27
|
+
"size": "size-limit",
|
|
28
|
+
"analyze": "size-limit --why"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@daouy/host": "^1.0.234",
|
|
32
|
+
"@types/node": "^14.0.26",
|
|
33
|
+
"@types/react": "^18.2.33",
|
|
34
|
+
"tsdx": "^0.14.1",
|
|
35
|
+
"tslib": "^2.2.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@daouy/host": "^1.0.234",
|
|
39
|
+
"@daouy/query": "^0.1.82",
|
|
40
|
+
"react": ">=16.8.0",
|
|
41
|
+
"react-dom": ">=16.8.0"
|
|
42
|
+
}
|
|
43
|
+
}
|