ab-ecosystem-cpass 1.0.10 → 1.0.12
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/client.d.ts +6 -0
- package/dist/client.js +7 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/embedded-signup.d.ts +29 -0
- package/dist/internal/embedded-signup.js +175 -0
- package/dist/internal/embedded-signup.js.map +1 -0
- package/dist/resources/channels/onboarding.d.ts +62 -0
- package/dist/resources/channels/onboarding.js +76 -0
- package/dist/resources/channels/onboarding.js.map +1 -0
- package/dist/resources/data-stores.d.ts +43 -0
- package/dist/resources/data-stores.js +43 -0
- package/dist/resources/data-stores.js.map +1 -1
- package/dist/types/channels.d.ts +79 -0
- package/docs/audience/canned-replies.md +3 -0
- package/docs/audience/contact-tags.md +4 -0
- package/docs/audience/contacts.md +23 -0
- package/docs/audience/crm-triggers.md +3 -0
- package/docs/audience/custom-fields.md +23 -0
- package/docs/audience/exports.md +6 -0
- package/docs/audience/imports.md +7 -0
- package/docs/audience/notifications.md +11 -0
- package/docs/audience/scheduled-messages.md +5 -0
- package/docs/audience/segments.md +4 -0
- package/docs/audience/webhooks.md +7 -0
- package/docs/campaign/campaigns.md +20 -0
- package/docs/channels/activity.md +3 -0
- package/docs/channels/billing.md +2 -0
- package/docs/channels/channel-props.md +19 -0
- package/docs/channels/channels.md +34 -2
- package/docs/channels/onboarding.md +324 -0
- package/docs/channels/templates.md +22 -0
- package/docs/channels/wallet.md +2 -0
- package/docs/channels/webhooks.md +6 -0
- package/docs/data-store.md +78 -0
- package/docs/inbox/connection.md +88 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -229,6 +229,7 @@ same pages ship inside the package, so they are readable offline at
|
|
|
229
229
|
| --- | --- | --- |
|
|
230
230
|
| `crm.channels` | [channels](https://github.com/udghatan-dev/crm-sdk/blob/main/packages/sdk-js/docs/channels/channels.md) | `list` `get` `updateDetails` `disable` `rotateToken` `getProp` `setProp` |
|
|
231
231
|
| — | [channel properties](https://github.com/udghatan-dev/crm-sdk/blob/main/packages/sdk-js/docs/channels/channel-props.md) | every `prop` `getProp`/`setProp` accepts |
|
|
232
|
+
| `crm.channelOnboarding` | [connecting a channel](https://github.com/udghatan-dev/crm-sdk/blob/main/packages/sdk-js/docs/channels/onboarding.md) | `types` `url` `exchange` `complete` `connect` |
|
|
232
233
|
| `crm.templates` | [templates](https://github.com/udghatan-dev/crm-sdk/blob/main/packages/sdk-js/docs/channels/templates.md) | `list` `get` `create` `update` `delete` `sync` |
|
|
233
234
|
| `crm.channelWebhooks` | [channel webhooks](https://github.com/udghatan-dev/crm-sdk/blob/main/packages/sdk-js/docs/channels/webhooks.md) | `list` `get` `create` `update` `delete` |
|
|
234
235
|
| `crm.billing` | [conversation billing](https://github.com/udghatan-dev/crm-sdk/blob/main/packages/sdk-js/docs/channels/billing.md) | `list` `stats` |
|
package/dist/client.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { InboxMedia } from './resources/audience/inbox-media';
|
|
|
14
14
|
import { Notifications } from './resources/audience/notifications';
|
|
15
15
|
import { DataStoreCollections, DataStoreRecords, DataStores } from './resources/data-stores';
|
|
16
16
|
import { Channels } from './resources/channels/channels';
|
|
17
|
+
import { ChannelOnboarding } from './resources/channels/onboarding';
|
|
17
18
|
import { Templates } from './resources/channels/templates';
|
|
18
19
|
import { ChannelWebhooks } from './resources/channels/webhooks';
|
|
19
20
|
import { Billing } from './resources/channels/billing';
|
|
@@ -95,6 +96,11 @@ export declare class CrmClient {
|
|
|
95
96
|
readonly dataStoreRecords: DataStoreRecords;
|
|
96
97
|
/** Channels, and the provider properties that hang off them. */
|
|
97
98
|
readonly channels: Channels;
|
|
99
|
+
/**
|
|
100
|
+
* Connecting a new channel. Separate from `channels` because it is the one
|
|
101
|
+
* channel operation that walks a person through a dialog on Meta's own site.
|
|
102
|
+
*/
|
|
103
|
+
readonly channelOnboarding: ChannelOnboarding;
|
|
98
104
|
/** WhatsApp message templates, per channel. */
|
|
99
105
|
readonly templates: Templates;
|
|
100
106
|
/** Channel webhooks: where a channel's message traffic is delivered. */
|
package/dist/client.js
CHANGED
|
@@ -19,6 +19,7 @@ const notifications_1 = require("./resources/audience/notifications");
|
|
|
19
19
|
const data_stores_1 = require("./resources/data-stores");
|
|
20
20
|
// Channels
|
|
21
21
|
const channels_1 = require("./resources/channels/channels");
|
|
22
|
+
const onboarding_1 = require("./resources/channels/onboarding");
|
|
22
23
|
const templates_1 = require("./resources/channels/templates");
|
|
23
24
|
const webhooks_2 = require("./resources/channels/webhooks");
|
|
24
25
|
const billing_1 = require("./resources/channels/billing");
|
|
@@ -103,6 +104,11 @@ class CrmClient {
|
|
|
103
104
|
// -- Channels -------------------------------------------------------------
|
|
104
105
|
/** Channels, and the provider properties that hang off them. */
|
|
105
106
|
channels;
|
|
107
|
+
/**
|
|
108
|
+
* Connecting a new channel. Separate from `channels` because it is the one
|
|
109
|
+
* channel operation that walks a person through a dialog on Meta's own site.
|
|
110
|
+
*/
|
|
111
|
+
channelOnboarding;
|
|
106
112
|
/** WhatsApp message templates, per channel. */
|
|
107
113
|
templates;
|
|
108
114
|
/** Channel webhooks: where a channel's message traffic is delivered. */
|
|
@@ -148,6 +154,7 @@ class CrmClient {
|
|
|
148
154
|
this.dataStoreCollections = new data_stores_1.DataStoreCollections(http);
|
|
149
155
|
this.dataStoreRecords = new data_stores_1.DataStoreRecords(http);
|
|
150
156
|
this.channels = new channels_1.Channels(http);
|
|
157
|
+
this.channelOnboarding = new onboarding_1.ChannelOnboarding(http);
|
|
151
158
|
this.templates = new templates_1.Templates(http);
|
|
152
159
|
this.channelWebhooks = new webhooks_2.ChannelWebhooks(http);
|
|
153
160
|
this.billing = new billing_1.Billing(http);
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRo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I,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;QAEnC,uEAAuE;QACvE,yEAAyE;QACzE,WAAW;QACX,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,gBAAgB,GAAG,IAAI,oCAAgB,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;CACF;AA1ID,8BA0IC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ export { CampaignMessages } from './resources/campaign-messages';
|
|
|
25
25
|
*/
|
|
26
26
|
export { MAX_BULK_RECEIVERS, buildReceivers, normaliseColumn, normaliseNumbers, parseDelimited, resolveAudience, type BulkAudienceInput, type CampaignReceiver, type ResolvedAudience, } from './resources/campaign-audience';
|
|
27
27
|
export { Channels, type SetPropOptions } from './resources/channels/channels';
|
|
28
|
+
export { ChannelOnboarding, type ConnectOptions } from './resources/channels/onboarding';
|
|
29
|
+
/** The popup driver on its own, for a console that calls `url()` itself. */
|
|
30
|
+
export { openSignup, EmbeddedSignupError, type OpenSignupOptions, } from './internal/embedded-signup';
|
|
28
31
|
export { Templates } from './resources/channels/templates';
|
|
29
32
|
export { ChannelWebhooks } from './resources/channels/webhooks';
|
|
30
33
|
export { Billing } from './resources/channels/billing';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Activity = exports.Wallet = exports.Billing = exports.ChannelWebhooks = exports.Templates = exports.Channels = exports.resolveAudience = exports.parseDelimited = exports.normaliseNumbers = exports.normaliseColumn = exports.buildReceivers = exports.MAX_BULK_RECEIVERS = exports.CampaignMessages = exports.Campaigns = exports.InboxMedia = exports.DataStoreRecords = exports.DataStoreCollections = exports.DataStores = exports.Notifications = exports.Webhooks = exports.Exports = exports.Imports = exports.CrmTriggers = exports.Segments = exports.CustomFields = exports.CannedReplies = exports.ContactNotes = exports.ContactTags = exports.Contacts = exports.CHANNELS = exports.AUDIENCE = void 0;
|
|
17
|
+
exports.Activity = exports.Wallet = exports.Billing = exports.ChannelWebhooks = exports.Templates = exports.EmbeddedSignupError = exports.openSignup = exports.ChannelOnboarding = exports.Channels = exports.resolveAudience = exports.parseDelimited = exports.normaliseNumbers = exports.normaliseColumn = exports.buildReceivers = exports.MAX_BULK_RECEIVERS = exports.CampaignMessages = exports.Campaigns = exports.InboxMedia = exports.DataStoreRecords = exports.DataStoreCollections = exports.DataStores = exports.Notifications = exports.Webhooks = exports.Exports = exports.Imports = exports.CrmTriggers = exports.Segments = exports.CustomFields = exports.CannedReplies = exports.ContactNotes = exports.ContactTags = exports.Contacts = exports.CHANNELS = exports.AUDIENCE = void 0;
|
|
18
18
|
__exportStar(require("./client"), exports);
|
|
19
19
|
__exportStar(require("./http"), exports);
|
|
20
20
|
__exportStar(require("./errors"), exports);
|
|
@@ -71,6 +71,12 @@ Object.defineProperty(exports, "resolveAudience", { enumerable: true, get: funct
|
|
|
71
71
|
// Channels
|
|
72
72
|
var channels_1 = require("./resources/channels/channels");
|
|
73
73
|
Object.defineProperty(exports, "Channels", { enumerable: true, get: function () { return channels_1.Channels; } });
|
|
74
|
+
var onboarding_1 = require("./resources/channels/onboarding");
|
|
75
|
+
Object.defineProperty(exports, "ChannelOnboarding", { enumerable: true, get: function () { return onboarding_1.ChannelOnboarding; } });
|
|
76
|
+
/** The popup driver on its own, for a console that calls `url()` itself. */
|
|
77
|
+
var embedded_signup_1 = require("./internal/embedded-signup");
|
|
78
|
+
Object.defineProperty(exports, "openSignup", { enumerable: true, get: function () { return embedded_signup_1.openSignup; } });
|
|
79
|
+
Object.defineProperty(exports, "EmbeddedSignupError", { enumerable: true, get: function () { return embedded_signup_1.EmbeddedSignupError; } });
|
|
74
80
|
var templates_1 = require("./resources/channels/templates");
|
|
75
81
|
Object.defineProperty(exports, "Templates", { enumerable: true, get: function () { return templates_1.Templates; } });
|
|
76
82
|
var webhooks_2 = require("./resources/channels/webhooks");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB;AAExB,2CAAuD;AAA9C,iGAAA,QAAQ,OAAA;AAAE,iGAAA,QAAQ,OAAA;AAE3B,WAAW;AACX,0DAAyD;AAAhD,oGAAA,QAAQ,OAAA;AACjB,kEAAgE;AAAvD,2GAAA,WAAW,OAAA;AACpB,oEAAkE;AAAzD,6GAAA,YAAY,OAAA;AACrB,sEAAoE;AAA3D,+GAAA,aAAa,OAAA;AACtB,oEAAkE;AAAzD,6GAAA,YAAY,OAAA;AACrB,0DAAyD;AAAhD,oGAAA,QAAQ,OAAA;AACjB,kEAAgE;AAAvD,2GAAA,WAAW,OAAA;AACpB,sEAA8D;AAArD,yGAAA,OAAO,OAAA;AAChB,sEAA8D;AAArD,yGAAA,OAAO,OAAA;AAChB,0DAAyD;AAAhD,oGAAA,QAAQ,OAAA;AACjB,oEAAmE;AAA1D,8GAAA,aAAa,OAAA;AACtB,uDAIiC;AAH/B,yGAAA,UAAU,OAAA;AACV,mHAAA,oBAAoB,OAAA;AACpB,+GAAA,gBAAgB,OAAA;AAElB,gEAI0C;AAHxC,yGAAA,UAAU,OAAA;AAKZ,WAAW;AACX,mDAS+B;AAR7B,sGAAA,SAAS,OAAA;AASX,mEAAiE;AAAxD,qHAAA,gBAAgB,OAAA;AACzB;;;;GAIG;AACH,mEAUuC;AATrC,uHAAA,kBAAkB,OAAA;AAClB,mHAAA,cAAc,OAAA;AACd,oHAAA,eAAe,OAAA;AACf,qHAAA,gBAAgB,OAAA;AAChB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,mEAUuC;AATrC,uHAAA,kBAAkB,OAAA;AAClB,mHAAA,cAAc,OAAA;AACd,oHAAA,eAAe,OAAA;AACf,qHAAA,gBAAgB,OAAA;AAChB,mHAAA,cAAc,OAAA;AACd,oHAAA,eAAe,OAAA;AAMjB,WAAW;AACX,0DAA8E;AAArE,oGAAA,QAAQ,OAAA;AACjB,8DAAyF;AAAhF,+GAAA,iBAAiB,OAAA;AAC1B,4EAA4E;AAC5E,8DAIoC;AAHlC,6GAAA,UAAU,OAAA;AACV,sHAAA,mBAAmB,OAAA;AAGrB,4DAA2D;AAAlD,sGAAA,SAAS,OAAA;AAClB,0DAAgE;AAAvD,2GAAA,eAAe,OAAA;AACxB,wDAAuD;AAA9C,kGAAA,OAAO,OAAA;AAChB,sDAAqD;AAA5C,gGAAA,MAAM,OAAA;AACf,0DAAyD;AAAhD,oGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SignupCredentials } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* The dialog answers in two halves -- the code on the redirect, the ids by
|
|
4
|
+
* `postMessage` -- and neither is usable alone, so `openSignup` waits for both.
|
|
5
|
+
*/
|
|
6
|
+
/** How the popup is opened, and how to follow its progress. */
|
|
7
|
+
export interface OpenSignupOptions {
|
|
8
|
+
/** Window name, so a second call reuses the popup rather than opening two. */
|
|
9
|
+
name?: string;
|
|
10
|
+
width?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
/** How long to wait for both halves. Default 15 minutes. */
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
/** For a console showing more than a spinner. `step` is Meta's own `current_step`. */
|
|
15
|
+
onProgress?: (event: {
|
|
16
|
+
phase: 'opened' | 'step' | 'code' | 'ids';
|
|
17
|
+
step?: string;
|
|
18
|
+
}) => void;
|
|
19
|
+
}
|
|
20
|
+
/** Thrown for every way the dialog can fail to produce credentials. */
|
|
21
|
+
export declare class EmbeddedSignupError extends Error {
|
|
22
|
+
readonly code: 'unsupported_environment' | 'popup_blocked' | 'popup_closed' | 'cancelled' | 'signup_error' | 'timeout';
|
|
23
|
+
constructor(code: 'unsupported_environment' | 'popup_blocked' | 'popup_closed' | 'cancelled' | 'signup_error' | 'timeout', message: string);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Call this **straight from a click handler**: a `window.open` a browser does not
|
|
27
|
+
* attribute to a gesture is blocked, and that looks like the user's popup blocker.
|
|
28
|
+
*/
|
|
29
|
+
export declare const openSignup: (url: string, options?: OpenSignupOptions) => Promise<SignupCredentials>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openSignup = exports.EmbeddedSignupError = void 0;
|
|
4
|
+
/** Thrown for every way the dialog can fail to produce credentials. */
|
|
5
|
+
class EmbeddedSignupError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
constructor(code, message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = 'EmbeddedSignupError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.EmbeddedSignupError = EmbeddedSignupError;
|
|
14
|
+
/** Origins Meta posts the signup events from. */
|
|
15
|
+
const META_ORIGINS = ['https://www.facebook.com', 'https://web.facebook.com', 'https://business.facebook.com'];
|
|
16
|
+
const DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
17
|
+
const browser = () => {
|
|
18
|
+
const candidate = globalThis.window;
|
|
19
|
+
return candidate && typeof candidate.open === 'function' ? candidate : undefined;
|
|
20
|
+
};
|
|
21
|
+
/** An object in most browsers, a JSON string in some. */
|
|
22
|
+
const parsePayload = (data) => {
|
|
23
|
+
if (typeof data === 'string') {
|
|
24
|
+
try {
|
|
25
|
+
const parsed = JSON.parse(data);
|
|
26
|
+
return typeof parsed === 'object' && parsed !== null ? parsed : undefined;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return typeof data === 'object' && data !== null ? data : undefined;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Call this **straight from a click handler**: a `window.open` a browser does not
|
|
36
|
+
* attribute to a gesture is blocked, and that looks like the user's popup blocker.
|
|
37
|
+
*/
|
|
38
|
+
const openSignup = (url, options = {}) => {
|
|
39
|
+
const win = browser();
|
|
40
|
+
if (!win) {
|
|
41
|
+
return Promise.reject(new EmbeddedSignupError('unsupported_environment', 'Embedded signup needs a browser; drive the three onboarding calls yourself outside one'));
|
|
42
|
+
}
|
|
43
|
+
const width = options.width ?? 620;
|
|
44
|
+
const height = options.height ?? 760;
|
|
45
|
+
const left = Math.max(0, ((win.screen?.width ?? width) - width) / 2);
|
|
46
|
+
const top = Math.max(0, ((win.screen?.height ?? height) - height) / 2);
|
|
47
|
+
const popup = win.open(url, options.name ?? 'wa_embedded_signup', `popup=1,width=${width},height=${height},left=${left},top=${top},scrollbars=1,resizable=1`);
|
|
48
|
+
if (!popup) {
|
|
49
|
+
return Promise.reject(new EmbeddedSignupError('popup_blocked', 'The signup window was blocked; allow popups and try again'));
|
|
50
|
+
}
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
let code;
|
|
53
|
+
let state;
|
|
54
|
+
let wabaId;
|
|
55
|
+
let phoneNumberId;
|
|
56
|
+
let settled = false;
|
|
57
|
+
const progress = (phase, step) => {
|
|
58
|
+
try {
|
|
59
|
+
options.onProgress?.({ phase, step });
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// A console's callback is not allowed to break the flow.
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const finish = (outcome) => {
|
|
66
|
+
if (settled)
|
|
67
|
+
return;
|
|
68
|
+
settled = true;
|
|
69
|
+
win.removeEventListener('message', onMessage);
|
|
70
|
+
win.clearInterval(poll);
|
|
71
|
+
win.clearTimeout(timer);
|
|
72
|
+
// On success too: the console is about to render that confirmation properly.
|
|
73
|
+
try {
|
|
74
|
+
if (!popup.closed)
|
|
75
|
+
popup.close();
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Cross-origin as it closed; the window is the user's problem now.
|
|
79
|
+
}
|
|
80
|
+
outcome();
|
|
81
|
+
};
|
|
82
|
+
/** Resolves only once both halves are in. */
|
|
83
|
+
const settleIfComplete = () => {
|
|
84
|
+
if (code && state && wabaId && phoneNumberId) {
|
|
85
|
+
const credentials = { code, state, wabaId, phoneNumberId };
|
|
86
|
+
finish(() => resolve(credentials));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const onMessage = (event) => {
|
|
90
|
+
const payload = parsePayload(event.data);
|
|
91
|
+
if (!payload)
|
|
92
|
+
return;
|
|
93
|
+
// Our own redirect page posting back, rather than the poll reading its URL.
|
|
94
|
+
if (event.origin === win.location.origin && payload.type === 'CRM_CHANNEL_ONBOARDING') {
|
|
95
|
+
if (typeof payload.code === 'string')
|
|
96
|
+
code = payload.code;
|
|
97
|
+
if (typeof payload.state === 'string')
|
|
98
|
+
state = payload.state;
|
|
99
|
+
if (code)
|
|
100
|
+
progress('code');
|
|
101
|
+
settleIfComplete();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!META_ORIGINS.includes(event.origin))
|
|
105
|
+
return;
|
|
106
|
+
if (payload.type !== 'WA_EMBEDDED_SIGNUP')
|
|
107
|
+
return;
|
|
108
|
+
const data = (payload.data ?? {});
|
|
109
|
+
// Backing out is not worth a stack trace, but it has to reject or the
|
|
110
|
+
// promise never settles.
|
|
111
|
+
if (payload.event === 'CANCEL') {
|
|
112
|
+
const step = typeof data.current_step === 'string' ? data.current_step : undefined;
|
|
113
|
+
finish(() => reject(new EmbeddedSignupError('cancelled', step ? `Signup was cancelled at the "${step}" step` : 'Signup was cancelled')));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (payload.event === 'ERROR') {
|
|
117
|
+
const message = typeof data.error_message === 'string' ? data.error_message : 'Meta reported an error';
|
|
118
|
+
finish(() => reject(new EmbeddedSignupError('signup_error', message)));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (typeof data.waba_id === 'string')
|
|
122
|
+
wabaId = data.waba_id;
|
|
123
|
+
if (typeof data.phone_number_id === 'string')
|
|
124
|
+
phoneNumberId = data.phone_number_id;
|
|
125
|
+
if (wabaId && phoneNumberId)
|
|
126
|
+
progress('ids');
|
|
127
|
+
else if (typeof data.current_step === 'string')
|
|
128
|
+
progress('step', data.current_step);
|
|
129
|
+
settleIfComplete();
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Same-origin once the dialog redirects to our `redirect_uri`; before that
|
|
133
|
+
* reading `location` throws. Also the only signal that the window was closed.
|
|
134
|
+
*/
|
|
135
|
+
const poll = win.setInterval(() => {
|
|
136
|
+
if (popup.closed) {
|
|
137
|
+
finish(() => reject(new EmbeddedSignupError('popup_closed', code || wabaId
|
|
138
|
+
? 'The signup window was closed before it finished'
|
|
139
|
+
: 'The signup window was closed')));
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (code)
|
|
143
|
+
return;
|
|
144
|
+
try {
|
|
145
|
+
const search = popup.location.search;
|
|
146
|
+
if (!search)
|
|
147
|
+
return;
|
|
148
|
+
const params = new URLSearchParams(search);
|
|
149
|
+
const returned = params.get('code');
|
|
150
|
+
if (!returned) {
|
|
151
|
+
// A refusal arrives here and never as a message; without this the
|
|
152
|
+
// popup just sits there.
|
|
153
|
+
const error = params.get('error_description') ?? params.get('error');
|
|
154
|
+
if (error)
|
|
155
|
+
finish(() => reject(new EmbeddedSignupError('signup_error', error)));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
code = returned;
|
|
159
|
+
state = params.get('state') ?? state;
|
|
160
|
+
progress('code');
|
|
161
|
+
settleIfComplete();
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
// Still on Meta's origin, so there is nothing to read yet.
|
|
165
|
+
}
|
|
166
|
+
}, 400);
|
|
167
|
+
const timer = win.setTimeout(() => {
|
|
168
|
+
finish(() => reject(new EmbeddedSignupError('timeout', 'The signup window was not completed in time')));
|
|
169
|
+
}, options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
170
|
+
win.addEventListener('message', onMessage);
|
|
171
|
+
progress('opened');
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
exports.openSignup = openSignup;
|
|
175
|
+
//# sourceMappingURL=embedded-signup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedded-signup.js","sourceRoot":"","sources":["../../src/internal/embedded-signup.ts"],"names":[],"mappings":";;;AAmBA,uEAAuE;AACvE,MAAa,mBAAoB,SAAQ,KAAK;IAEjC;IADX,YACW,IAMI,EACb,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QATN,SAAI,GAAJ,IAAI,CAMA;QAIb,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAdD,kDAcC;AAED,iDAAiD;AACjD,MAAM,YAAY,GAAG,CAAC,0BAA0B,EAAE,0BAA0B,EAAE,+BAA+B,CAAC,CAAC;AAE/G,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAoB1C,MAAM,OAAO,GAAG,GAA8B,EAAE;IAC9C,MAAM,SAAS,GAAI,UAAmC,CAAC,MAAmC,CAAC;IAC3F,OAAO,SAAS,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AACnF,CAAC,CAAC;AAEF,yDAAyD;AACzD,MAAM,YAAY,GAAG,CAAC,IAAa,EAAuC,EAAE;IAC1E,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA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@
|
|
|
1
|
+
import type { ChannelOnboardingOption, ChannelResponse, CompleteOnboardingInput, OnboardingChannelType, OnboardingExchangeInput, OnboardingExchangeResult, OnboardingUrlInput, OnboardingUrlResult } from '../../types';
|
|
2
|
+
import type { HttpClient } from '../../http';
|
|
3
|
+
import { type OpenSignupOptions } from '../../internal/embedded-signup';
|
|
4
|
+
/** Options for the one-call driver. */
|
|
5
|
+
export interface ConnectOptions extends OpenSignupOptions {
|
|
6
|
+
/** Which family to connect. Only `whatsapp` today, and the default. */
|
|
7
|
+
type?: OnboardingChannelType;
|
|
8
|
+
/** The inclusion to spend, when the plan carries more than one. */
|
|
9
|
+
slug?: string;
|
|
10
|
+
/** A non-default redirect, which must be one the service is configured for. */
|
|
11
|
+
redirectUri?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Connecting a channel. `connect()` does steps 1 to 3 and hands back the number
|
|
15
|
+
* to confirm; or call `url()`, open the dialog yourself, then `exchange()`.
|
|
16
|
+
* Either way the browser never sees a Meta credential.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* // In the click handler for "Connect WhatsApp" -- not after an await.
|
|
20
|
+
* const candidate = await crm.channelOnboarding.connect();
|
|
21
|
+
* // Show candidate.phoneNumber, prefill a form from candidate.defaults...
|
|
22
|
+
* const { data: channel } = await crm.channelOnboarding.complete({
|
|
23
|
+
* token: candidate.id,
|
|
24
|
+
* name: form.name,
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class ChannelOnboarding {
|
|
29
|
+
private readonly http;
|
|
30
|
+
constructor(http: HttpClient);
|
|
31
|
+
/**
|
|
32
|
+
* `GET /v1/channels/onboarding/types` -- every family, available or not, so a
|
|
33
|
+
* picker greys rows out. Check `available`, show `reason`. Scope: `channels:read`.
|
|
34
|
+
*/
|
|
35
|
+
types(): Promise<{
|
|
36
|
+
data: ChannelOnboardingOption[];
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* `POST /v1/channels/onboarding/url` -- the dialog URL and the `state` to hand
|
|
40
|
+
* back. **Meta refuses to be framed**: use a popup. 402 if the plan has no room.
|
|
41
|
+
*/
|
|
42
|
+
url(input?: OnboardingUrlInput): Promise<{
|
|
43
|
+
data: OnboardingUrlResult;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* `POST /v1/channels/onboarding/exchange` -- redeems the code. **Creates
|
|
47
|
+
* nothing**: show `phoneNumber`, Meta's own description, and let them confirm.
|
|
48
|
+
*/
|
|
49
|
+
exchange(input: OnboardingExchangeInput): Promise<{
|
|
50
|
+
data: OnboardingExchangeResult;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* `POST /v1/channels/onboarding/complete` -- creates the channel, **inactive**:
|
|
54
|
+
* `setProp(id, 'wa_pin_update')` brings it up, or `wa_biz_update` for a WA Biz number.
|
|
55
|
+
*/
|
|
56
|
+
complete(input: CompleteOnboardingInput): Promise<ChannelResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* The URL, the dialog and the exchange in one call. **Call it straight from the
|
|
59
|
+
* click handler**, or the popup is blocked. Rejects with `EmbeddedSignupError`.
|
|
60
|
+
*/
|
|
61
|
+
connect(options?: ConnectOptions): Promise<OnboardingExchangeResult>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChannelOnboarding = void 0;
|
|
4
|
+
const paths_1 = require("../paths");
|
|
5
|
+
const embedded_signup_1 = require("../../internal/embedded-signup");
|
|
6
|
+
const ONBOARDING = `${paths_1.CHANNELS}/onboarding`;
|
|
7
|
+
/**
|
|
8
|
+
* Connecting a channel. `connect()` does steps 1 to 3 and hands back the number
|
|
9
|
+
* to confirm; or call `url()`, open the dialog yourself, then `exchange()`.
|
|
10
|
+
* Either way the browser never sees a Meta credential.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* // In the click handler for "Connect WhatsApp" -- not after an await.
|
|
14
|
+
* const candidate = await crm.channelOnboarding.connect();
|
|
15
|
+
* // Show candidate.phoneNumber, prefill a form from candidate.defaults...
|
|
16
|
+
* const { data: channel } = await crm.channelOnboarding.complete({
|
|
17
|
+
* token: candidate.id,
|
|
18
|
+
* name: form.name,
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
class ChannelOnboarding {
|
|
23
|
+
http;
|
|
24
|
+
constructor(http) {
|
|
25
|
+
this.http = http;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* `GET /v1/channels/onboarding/types` -- every family, available or not, so a
|
|
29
|
+
* picker greys rows out. Check `available`, show `reason`. Scope: `channels:read`.
|
|
30
|
+
*/
|
|
31
|
+
types() {
|
|
32
|
+
return this.http.request('GET', `${ONBOARDING}/types`);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `POST /v1/channels/onboarding/url` -- the dialog URL and the `state` to hand
|
|
36
|
+
* back. **Meta refuses to be framed**: use a popup. 402 if the plan has no room.
|
|
37
|
+
*/
|
|
38
|
+
url(input = {}) {
|
|
39
|
+
return this.http.request('POST', `${ONBOARDING}/url`, { body: input });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `POST /v1/channels/onboarding/exchange` -- redeems the code. **Creates
|
|
43
|
+
* nothing**: show `phoneNumber`, Meta's own description, and let them confirm.
|
|
44
|
+
*/
|
|
45
|
+
exchange(input) {
|
|
46
|
+
return this.http.request('POST', `${ONBOARDING}/exchange`, {
|
|
47
|
+
body: input,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `POST /v1/channels/onboarding/complete` -- creates the channel, **inactive**:
|
|
52
|
+
* `setProp(id, 'wa_pin_update')` brings it up, or `wa_biz_update` for a WA Biz number.
|
|
53
|
+
*/
|
|
54
|
+
complete(input) {
|
|
55
|
+
return this.http.request('POST', `${ONBOARDING}/complete`, { body: input });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The URL, the dialog and the exchange in one call. **Call it straight from the
|
|
59
|
+
* click handler**, or the popup is blocked. Rejects with `EmbeddedSignupError`.
|
|
60
|
+
*/
|
|
61
|
+
async connect(options = {}) {
|
|
62
|
+
const { type, slug, redirectUri, ...popup } = options;
|
|
63
|
+
const { data: session } = await this.url({ type, slug, redirectUri });
|
|
64
|
+
const credentials = await (0, embedded_signup_1.openSignup)(session.url, popup);
|
|
65
|
+
const { data } = await this.exchange({
|
|
66
|
+
// The one we issued, since the dialog may or may not return it.
|
|
67
|
+
state: session.state,
|
|
68
|
+
code: credentials.code,
|
|
69
|
+
wabaId: credentials.wabaId,
|
|
70
|
+
phoneNumberId: credentials.phoneNumberId,
|
|
71
|
+
});
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.ChannelOnboarding = ChannelOnboarding;
|
|
76
|
+
//# sourceMappingURL=onboarding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.js","sourceRoot":"","sources":["../../../src/resources/channels/onboarding.ts"],"names":[],"mappings":";;;AAYA,oCAAoC;AACpC,oEAAoF;AAEpF,MAAM,UAAU,GAAG,GAAG,gBAAQ,aAAa,CAAC;AAY5C;;;;;;;;;;;;;;GAcG;AACH,MAAa,iBAAiB;IACC;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAsC,KAAK,EAAE,GAAG,UAAU,QAAQ,CAAC,CAAC;IAC9F,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,QAA4B,EAAE;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAgC,MAAM,EAAE,GAAG,UAAU,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACxG,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAA8B;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAqC,MAAM,EAAE,GAAG,UAAU,WAAW,EAAE;YAC7F,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAA8B;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAkB,MAAM,EAAE,GAAG,UAAU,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,UAA0B,EAAE;QACxC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;QACtD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QAEtE,MAAM,WAAW,GAAsB,MAAM,IAAA,4BAAU,EAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAE5E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC;YACnC,gEAAgE;YAChE,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,aAAa,EAAE,WAAW,CAAC,aAAa;SACzC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAzDD,8CAyDC"}
|
|
@@ -58,6 +58,23 @@ import type { HttpClient } from '../http';
|
|
|
58
58
|
* is returned -- no host, no user, no connection string -- because there is no
|
|
59
59
|
* second way in: the API is the only door to those records.
|
|
60
60
|
*
|
|
61
|
+
* That extends to its failures. On a `self` store an upstream error carries the
|
|
62
|
+
* database's own message, because it is yours and the detail is what you act on
|
|
63
|
+
* (`datastore_auth_failed` with the reason, `datastore_unreachable` pointing at
|
|
64
|
+
* an IP access list). On a `cloud` store every upstream failure is one code --
|
|
65
|
+
* `502 datastore_unavailable`, no details -- because the cluster is the
|
|
66
|
+
* platform's and nothing in that message would be yours to fix. Refusals about
|
|
67
|
+
* *your request* are reported in full either way.
|
|
68
|
+
*
|
|
69
|
+
* ## A record is a row, not a file
|
|
70
|
+
*
|
|
71
|
+
* Records hold structured values. **Files are refused**, in either kind of
|
|
72
|
+
* store: a `data:` URI or base64 that begins with a known file signature comes
|
|
73
|
+
* back `422` however small it is, and every value and every record is capped --
|
|
74
|
+
* see `insert` for the numbers. Put the file in object storage and store its
|
|
75
|
+
* URL, which is cheaper, cacheable, and does not pass through this API on every
|
|
76
|
+
* page read.
|
|
77
|
+
*
|
|
61
78
|
* Which also means every record call costs a round trip to your database. The
|
|
62
79
|
* platform keeps the connection open between calls, so that is one query's
|
|
63
80
|
* latency rather than a fresh TLS handshake each time, but a loop of a thousand
|
|
@@ -162,6 +179,7 @@ export declare class DataStores {
|
|
|
162
179
|
* | 422 | `invalid_datastore_host` | The host does not resolve, or resolves somewhere private. |
|
|
163
180
|
* | 502 | `datastore_auth_failed` | The database refused the username or password. |
|
|
164
181
|
* | 502 | `datastore_unreachable` | No answer in time -- usually an IP access list. |
|
|
182
|
+
* | 502 | `datastore_unavailable` | A `cloud` store only: the platform's cluster did not answer. Nothing for you to fix; retry. |
|
|
165
183
|
*
|
|
166
184
|
* Scope: `datastores:write`.
|
|
167
185
|
*/
|
|
@@ -402,6 +420,31 @@ export declare class DataStoreCollections {
|
|
|
402
420
|
*/
|
|
403
421
|
export declare class DataStoreRecords {
|
|
404
422
|
private readonly http;
|
|
423
|
+
/**
|
|
424
|
+
* ## What a record may hold
|
|
425
|
+
*
|
|
426
|
+
* Structured values -- text, numbers, booleans, dates, short lists. **Not
|
|
427
|
+
* files.** A record is a row: every read of a page carries every byte of it
|
|
428
|
+
* back through the API, uncached and unstreamed, so one embedded image turns
|
|
429
|
+
* a 25-row page into a response nobody wants. The file belongs in object
|
|
430
|
+
* storage with its URL in the record.
|
|
431
|
+
*
|
|
432
|
+
* Refused with `422 validation_failed`, keyed by the field:
|
|
433
|
+
*
|
|
434
|
+
* | | |
|
|
435
|
+
* | --- | --- |
|
|
436
|
+
* | A `data:` URI | At any size. Unambiguously a file. |
|
|
437
|
+
* | Base64 starting with a file signature | PNG, JPEG, GIF, WebP, PDF, ZIP, MP3, MP4, WebM -- only for values of 64 characters or more, so a short string that happens to start that way is fine. |
|
|
438
|
+
* | A raw file header | `%PDF-`, `GIF89a`, the PNG and JPEG magic bytes, a ZIP header. |
|
|
439
|
+
* | `$binary`, `$uuid`, `$code`, `$function`, `$where` | Extended-JSON keys anywhere inside an `Array` value: binary and stored JavaScript, by another route. |
|
|
440
|
+
* | A value over **16KB** | Serialised. Generous for text, hopeless for media. |
|
|
441
|
+
* | A record over **64KB** | The finished document, so a hundred legal fields cannot add up to an illegal row. |
|
|
442
|
+
* | An array over **1000 items**, or nesting deeper than **8** | A list of options, not a dataset. |
|
|
443
|
+
*
|
|
444
|
+
* The same rules apply to `insert`, `update` and `bulkUpdate`, and to a
|
|
445
|
+
* `cloud` store and your own alike -- the cost is the round trip, which both
|
|
446
|
+
* pay.
|
|
447
|
+
*/
|
|
405
448
|
constructor(http: HttpClient);
|
|
406
449
|
/**
|
|
407
450
|
* `POST /v1/datastores/:store/collections/:collection/records` -- 201.
|
|
@@ -65,6 +65,23 @@ const recordsPath = (store, collection) => `${collectionPath(store, collection)}
|
|
|
65
65
|
* is returned -- no host, no user, no connection string -- because there is no
|
|
66
66
|
* second way in: the API is the only door to those records.
|
|
67
67
|
*
|
|
68
|
+
* That extends to its failures. On a `self` store an upstream error carries the
|
|
69
|
+
* database's own message, because it is yours and the detail is what you act on
|
|
70
|
+
* (`datastore_auth_failed` with the reason, `datastore_unreachable` pointing at
|
|
71
|
+
* an IP access list). On a `cloud` store every upstream failure is one code --
|
|
72
|
+
* `502 datastore_unavailable`, no details -- because the cluster is the
|
|
73
|
+
* platform's and nothing in that message would be yours to fix. Refusals about
|
|
74
|
+
* *your request* are reported in full either way.
|
|
75
|
+
*
|
|
76
|
+
* ## A record is a row, not a file
|
|
77
|
+
*
|
|
78
|
+
* Records hold structured values. **Files are refused**, in either kind of
|
|
79
|
+
* store: a `data:` URI or base64 that begins with a known file signature comes
|
|
80
|
+
* back `422` however small it is, and every value and every record is capped --
|
|
81
|
+
* see `insert` for the numbers. Put the file in object storage and store its
|
|
82
|
+
* URL, which is cheaper, cacheable, and does not pass through this API on every
|
|
83
|
+
* page read.
|
|
84
|
+
*
|
|
68
85
|
* Which also means every record call costs a round trip to your database. The
|
|
69
86
|
* platform keeps the connection open between calls, so that is one query's
|
|
70
87
|
* latency rather than a fresh TLS handshake each time, but a loop of a thousand
|
|
@@ -171,6 +188,7 @@ class DataStores {
|
|
|
171
188
|
* | 422 | `invalid_datastore_host` | The host does not resolve, or resolves somewhere private. |
|
|
172
189
|
* | 502 | `datastore_auth_failed` | The database refused the username or password. |
|
|
173
190
|
* | 502 | `datastore_unreachable` | No answer in time -- usually an IP access list. |
|
|
191
|
+
* | 502 | `datastore_unavailable` | A `cloud` store only: the platform's cluster did not answer. Nothing for you to fix; retry. |
|
|
174
192
|
*
|
|
175
193
|
* Scope: `datastores:write`.
|
|
176
194
|
*/
|
|
@@ -439,6 +457,31 @@ exports.DataStoreCollections = DataStoreCollections;
|
|
|
439
457
|
*/
|
|
440
458
|
class DataStoreRecords {
|
|
441
459
|
http;
|
|
460
|
+
/**
|
|
461
|
+
* ## What a record may hold
|
|
462
|
+
*
|
|
463
|
+
* Structured values -- text, numbers, booleans, dates, short lists. **Not
|
|
464
|
+
* files.** A record is a row: every read of a page carries every byte of it
|
|
465
|
+
* back through the API, uncached and unstreamed, so one embedded image turns
|
|
466
|
+
* a 25-row page into a response nobody wants. The file belongs in object
|
|
467
|
+
* storage with its URL in the record.
|
|
468
|
+
*
|
|
469
|
+
* Refused with `422 validation_failed`, keyed by the field:
|
|
470
|
+
*
|
|
471
|
+
* | | |
|
|
472
|
+
* | --- | --- |
|
|
473
|
+
* | A `data:` URI | At any size. Unambiguously a file. |
|
|
474
|
+
* | Base64 starting with a file signature | PNG, JPEG, GIF, WebP, PDF, ZIP, MP3, MP4, WebM -- only for values of 64 characters or more, so a short string that happens to start that way is fine. |
|
|
475
|
+
* | A raw file header | `%PDF-`, `GIF89a`, the PNG and JPEG magic bytes, a ZIP header. |
|
|
476
|
+
* | `$binary`, `$uuid`, `$code`, `$function`, `$where` | Extended-JSON keys anywhere inside an `Array` value: binary and stored JavaScript, by another route. |
|
|
477
|
+
* | A value over **16KB** | Serialised. Generous for text, hopeless for media. |
|
|
478
|
+
* | A record over **64KB** | The finished document, so a hundred legal fields cannot add up to an illegal row. |
|
|
479
|
+
* | An array over **1000 items**, or nesting deeper than **8** | A list of options, not a dataset. |
|
|
480
|
+
*
|
|
481
|
+
* The same rules apply to `insert`, `update` and `bulkUpdate`, and to a
|
|
482
|
+
* `cloud` store and your own alike -- the cost is the round trip, which both
|
|
483
|
+
* pay.
|
|
484
|
+
*/
|
|
442
485
|
constructor(http) {
|
|
443
486
|
this.http = http;
|
|
444
487
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-stores.js","sourceRoot":"","sources":["../../src/resources/data-stores.ts"],"names":[],"mappings":";;;AAuBA,mCAAyC;AAEzC,MAAM,IAAI,GAAG,iBAAS,CAAC;AAEvB,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,IAAA,WAAG,EAAC,KAAK,CAAC,EAAE,CAAC;AAC7D,MAAM,eAAe,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC;AAC7E,MAAM,cAAc,GAAG,CAAC,KAAa,EAA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