@foir/sdk 0.21.0 → 0.22.0
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/CHANGELOG.md +84 -1
- package/README.md +9 -9
- package/dist/app/client.d.ts +90 -84
- package/dist/app/contract/proto/apps/v1/apps_pb.d.ts +14 -13
- package/dist/app/dispatch.d.ts +5 -5
- package/dist/app/errors.d.ts +11 -11
- package/dist/app/index.d.ts +4 -4
- package/dist/app/naming.d.ts +1 -1
- package/dist/app/ticket.d.ts +2 -2
- package/dist/app/vocabulary.generated.d.ts +2 -2
- package/dist/app-contract.js +3 -3
- package/dist/app.js +92 -90
- package/dist/auth/access.d.ts +19 -19
- package/dist/auth/auth.d.ts +216 -114
- package/dist/auth/hosted.d.ts +14 -14
- package/dist/auth/index.d.ts +7 -7
- package/dist/auth/operations.d.ts +128 -32
- package/dist/auth/ops.d.ts +39 -21
- package/dist/auth/session-client.d.ts +3 -3
- package/dist/auth-session.js +3 -3
- package/dist/auth.js +234 -135
- package/dist/client.js +4 -4
- package/dist/data/builtins.d.ts +26 -26
- package/dist/data/client.d.ts +2 -2
- package/dist/data/decimal.d.ts +1 -1
- package/dist/data/index.d.ts +1 -1
- package/dist/data/manifest.d.ts +1 -1
- package/dist/data/schema.d.ts +1 -1
- package/dist/data/transport.d.ts +10 -10
- package/dist/data/ws-transport.d.ts +1 -1
- package/dist/data.js +6 -6
- package/dist/graphql/content-client.d.ts +13 -13
- package/dist/live/drift.d.ts +1 -1
- package/dist/media/screen-capture.d.ts +1 -1
- package/dist/next/index.d.ts +2 -2
- package/dist/next/session.d.ts +10 -10
- package/dist/next.js +77 -56
- package/dist/placement/index.d.ts +13 -13
- package/dist/placement.js +9 -6
- package/dist/push.js +61 -40
- package/dist/react/FoirFeedback.d.ts +2 -2
- package/dist/react/FoirProvider.d.ts +23 -23
- package/dist/react/SignIn.d.ts +4 -4
- package/dist/react/UserButton.d.ts +1 -1
- package/dist/react/feedback-notes.d.ts +4 -4
- package/dist/react/index.d.ts +3 -3
- package/dist/react.js +119 -95
- package/dist/realtime/index.d.ts +1 -1
- package/dist/server/callback-client.d.ts +4 -4
- package/dist/server/events-client.d.ts +16 -16
- package/dist/server/operation-types.d.ts +8 -8
- package/dist/server/require-scoped-token.d.ts +3 -3
- package/dist/server/types.d.ts +1 -1
- package/dist/server/verify-scoped-token.d.ts +3 -3
- package/dist/server.js +16 -13
- package/dist/transport/foir-http.d.ts +13 -13
- package/dist/types/index.d.ts +2 -2
- package/package.json +3 -3
package/dist/app/dispatch.d.ts
CHANGED
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
* and every run a hook, a schedule or `execute<Op>`
|
|
11
11
|
* starts.
|
|
12
12
|
* a direct call `{ project, app, operation, triggered_by,
|
|
13
|
-
* execution_id, input? }`:
|
|
13
|
+
* execution_id, input? }`: somebody running a SYNC
|
|
14
14
|
* operation from the console, discovery during setup,
|
|
15
15
|
* and the uninstall teardown. Nothing is queued, so
|
|
16
16
|
* `execution_id` is the id of the token the call
|
|
17
17
|
* carried and no execution holds it.
|
|
18
18
|
* the credential probe `{ project, app, operation, values }`: the reserved
|
|
19
19
|
* `__validate_credentials` operation, sent the
|
|
20
|
-
* credential
|
|
20
|
+
* credential somebody is about to save.
|
|
21
21
|
*
|
|
22
22
|
* `readAppDispatch` reads the first two as one shape. `readCredentialProbe`
|
|
23
23
|
* reads the third.
|
|
@@ -44,19 +44,19 @@ export interface AppDispatch {
|
|
|
44
44
|
* Read an app operation's dispatch body, already parsed from JSON.
|
|
45
45
|
*
|
|
46
46
|
* It does not refuse a body it cannot place: a direct call may carry no input
|
|
47
|
-
* and no id, and an endpoint that answered 4xx to one would fail
|
|
47
|
+
* and no id, and an endpoint that answered 4xx to one would fail somebody's
|
|
48
48
|
* action over a field it does not need. What is absent is absent on the
|
|
49
49
|
* answer.
|
|
50
50
|
*/
|
|
51
51
|
export declare function readAppDispatch(body: unknown): AppDispatch;
|
|
52
52
|
/**
|
|
53
|
-
* Read the credential probe's body: the values
|
|
53
|
+
* Read the credential probe's body: the values somebody submitted, by the
|
|
54
54
|
* manifest's credential field names. Every value the credential store accepts
|
|
55
55
|
* is a string, so anything else is left out rather than handed on as a
|
|
56
56
|
* surprise.
|
|
57
57
|
*
|
|
58
58
|
* The probe carries no `X-Foir-Context`, and whatever answers it with a
|
|
59
|
-
* non-2xx blocks
|
|
59
|
+
* non-2xx blocks their save. So answer 400 only for a value they can
|
|
60
60
|
* retype, and 200 for everything else, including a check you could not run.
|
|
61
61
|
*/
|
|
62
62
|
export declare function readCredentialProbe(body: unknown): {
|
package/dist/app/errors.d.ts
CHANGED
|
@@ -25,34 +25,34 @@ export interface AppLookupConflict {
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function appLookupConflictOf(error: unknown): AppLookupConflict | null;
|
|
27
27
|
/**
|
|
28
|
-
* A save to a
|
|
28
|
+
* A save to a user's record refused because no user holds the
|
|
29
29
|
* identity at the install's level and no email came to make one, or null for
|
|
30
|
-
* any other failure. Nothing is wrong with the row: the
|
|
30
|
+
* any other failure. Nothing is wrong with the row: the user is known once
|
|
31
31
|
* they sign in with the sign-in the install pairs with the source.
|
|
32
32
|
*/
|
|
33
|
-
export declare function
|
|
33
|
+
export declare function appUserUnlinkedOf(error: unknown): {
|
|
34
34
|
model: string;
|
|
35
35
|
identityProvider: string;
|
|
36
36
|
} | null;
|
|
37
37
|
/**
|
|
38
|
-
* Why a project cannot send a
|
|
39
|
-
* URL is set for the project, or for the
|
|
38
|
+
* Why a project cannot send a user an email. `NO_APP_BASE_URL`: no App base
|
|
39
|
+
* URL is set for the project, or for the user's organization. A reason
|
|
40
40
|
* this build does not know arrives as the platform spelled it.
|
|
41
41
|
*/
|
|
42
|
-
export type
|
|
42
|
+
export type AppUserEmailUnavailableReason = 'NO_APP_BASE_URL' | (string & {});
|
|
43
43
|
/** The reason as the platform sent it, or null when it sent none. */
|
|
44
|
-
export declare function
|
|
44
|
+
export declare function userEmailUnavailableReasonOf(value: unknown): AppUserEmailUnavailableReason | null;
|
|
45
45
|
/**
|
|
46
|
-
* A request refused because it would send a
|
|
46
|
+
* A request refused because it would send a user an email the project
|
|
47
47
|
* cannot send, or null for any other failure. Nothing was written and nothing
|
|
48
48
|
* was queued. An opt-in to a category confirmed by email is refused this way,
|
|
49
49
|
* and so is a notification that carries an email.
|
|
50
50
|
*
|
|
51
|
-
* It is about the project, not the
|
|
51
|
+
* It is about the project, not the user: the project's team fixes it,
|
|
52
52
|
* and the same request goes once they have.
|
|
53
53
|
*/
|
|
54
|
-
export declare function
|
|
55
|
-
reason:
|
|
54
|
+
export declare function appUserEmailUnavailableOf(error: unknown): {
|
|
55
|
+
reason: AppUserEmailUnavailableReason;
|
|
56
56
|
} | null;
|
|
57
57
|
/**
|
|
58
58
|
* Whether a read failed because the token is not served the field it asked
|
package/dist/app/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* createAppClient call Foir as the install, with the token a dispatch
|
|
12
12
|
* carried: its configuration, credential and status,
|
|
13
|
-
* records of the models it maps,
|
|
13
|
+
* records of the models it maps, users and
|
|
14
14
|
* notifications.
|
|
15
15
|
* readAppDispatch the body of a dispatch, whichever way it arrived,
|
|
16
16
|
* readCredentialProbe and of the credential probe.
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
* The manifest's own messages are on `@foir/sdk/app/contract`.
|
|
22
22
|
*/
|
|
23
23
|
export { createAppClient } from './client';
|
|
24
|
-
export type { AppBinding, AppClient, AppClientConfig, AppConsentChange, AppConsentSubject,
|
|
25
|
-
export {
|
|
26
|
-
export type {
|
|
24
|
+
export type { AppBinding, AppClient, AppClientConfig, AppConsentChange, AppConsentSubject, AppUser, AppUserEraseResult, AppUserList, AppUserSaveResult, AppFieldMapping, AppInstallConfig, AppNotification, AppOperationStart, AppOrganizationProvision, AppRecord, AppRecordList, AppStartedOperation, AppStatusReport, AppSyncDirection, AppUpsertResult, AppWhoami, } from './client';
|
|
25
|
+
export { appUserEmailUnavailableOf, appUserUnlinkedOf, appLookupConflictOf, isAppFieldWithheld } from './errors';
|
|
26
|
+
export type { AppUserEmailUnavailableReason, AppLookupConflict } from './errors';
|
|
27
27
|
export { appModelFieldName, appModelTypeName, appSelectorEnumValue } from './naming';
|
|
28
28
|
export { RECORD_KEY_RULE, recordKeyRefusal } from './record-key';
|
|
29
29
|
export { readAppDispatch, readCredentialProbe } from './dispatch';
|
package/dist/app/naming.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* model's key: the singular query, `delete<Type>`, `<Type>WhereInput` and the
|
|
6
6
|
* rest. A client generated for one project reads those names off the schema.
|
|
7
7
|
* An app installed in many projects cannot, because the model is whichever one
|
|
8
|
-
* each
|
|
8
|
+
* each project mapped, so it derives them from the key the same way the
|
|
9
9
|
* schema does.
|
|
10
10
|
*
|
|
11
11
|
* The rule: split the key on every run of characters that are not letters or
|
package/dist/app/ticket.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The exchange ticket: how an app's own OAuth callback gets to write the
|
|
3
3
|
* credential it was just granted.
|
|
4
4
|
*
|
|
5
|
-
* An install that needs a vendor's consent sends
|
|
5
|
+
* An install that needs a vendor's consent sends whoever is installing it to the app's
|
|
6
6
|
* authorize route with a single-use ticket. When the vendor returns them, the
|
|
7
7
|
* app redeems the ticket for a short-lived token that can do one thing: write
|
|
8
8
|
* this install's credential. It cannot read the configuration, report status
|
|
@@ -26,7 +26,7 @@ export interface RedeemedExchangeTicket {
|
|
|
26
26
|
/**
|
|
27
27
|
* Redeem an exchange ticket. ONE ATTEMPT, on purpose: the ticket is single-use,
|
|
28
28
|
* so repeating a call whose answer was lost would find the ticket spent, and
|
|
29
|
-
*
|
|
29
|
+
* their only way forward would be to start the install again. A
|
|
30
30
|
* failure here is the answer.
|
|
31
31
|
*/
|
|
32
32
|
export declare function redeemExchangeTicket(options: {
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* manifest's hook may subscribe to (an event of the project, that something
|
|
4
4
|
* emits) is the platform's to say: `validateAppManifest` answers it.
|
|
5
5
|
*/
|
|
6
|
-
export declare const APP_HOOK_EVENTS: readonly ["RECORD_CREATED", "RECORD_UPDATED", "RECORD_DELETED", "RECORD_PUBLISHED", "RECORD_UNPUBLISHED", "
|
|
6
|
+
export declare const APP_HOOK_EVENTS: readonly ["RECORD_CREATED", "RECORD_UPDATED", "RECORD_DELETED", "RECORD_PUBLISHED", "RECORD_UNPUBLISHED", "USER_CREATED", "USER_UPDATED", "USER_DELETED", "USER_MERGED", "SESSION_REVOKED", "OPERATION_COMPLETED", "OPERATION_FAILED", "OPERATION_CANCELLED", "OPERATION_TIMED_OUT", "MEMBERSHIP_GRANTED", "MEMBERSHIP_REVOKED", "MEMBERSHIP_ROLE_CHANGED", "TENANT_PLAN_CHANGED", "TENANT_SUBSCRIPTION_STATUS_CHANGED", "PROJECT_CREATED", "PROJECT_ARCHIVED", "INVITATION_ACCEPTED", "IMPORT_COMPLETED", "MIGRATION_APPLIED", "BULK_UPDATE_COMPLETED", "BULK_PUBLISH_COMPLETED", "USER_PREFERENCE_CHANGED", "ORGANIZATION_CREATED", "ORGANIZATION_UPDATED", "ORGANIZATION_MOVED", "ORGANIZATION_SUSPENDED", "ORGANIZATION_RESUMED", "ORGANIZATION_DELETION_SCHEDULED", "ORGANIZATION_DELETION_CANCELLED", "ORGANIZATION_DELETED", "ORGANIZATION_MEMBER_ADDED", "ORGANIZATION_MEMBER_REMOVED", "ORGANIZATION_MEMBER_ROLE_CHANGED", "PROJECT_REACTIVATED"];
|
|
7
7
|
/** An event a hook can name. */
|
|
8
8
|
export type AppHookEvent = (typeof APP_HOOK_EVENTS)[number];
|
|
9
9
|
/**
|
|
10
10
|
* The grants an operation declares as written, in the permission catalogue's
|
|
11
11
|
* names.
|
|
12
12
|
*/
|
|
13
|
-
export declare const APP_GRANTS: readonly ["appconfig:read", "appsecrets:delete", "appsecrets:list", "appsecrets:put", "appsecrets:read", "files:delete", "files:delete.all", "files:read", "files:read.all", "files:write", "files:write.all", "identities:delete", "identities:read", "notifications:consent", "notifications:read", "notifications:write.named", "operations:complete", "organizations:create", "organizations:delete", "status:write", "users:create", "users:read.all", "users:read.named"];
|
|
13
|
+
export declare const APP_GRANTS: readonly ["appconfig:read", "appsecrets:delete", "appsecrets:list", "appsecrets:put", "appsecrets:read", "files:delete", "files:delete.all", "files:read", "files:read.all", "files:write", "files:write.all", "identities:delete", "identities:read", "notifications:consent", "notifications:read", "notifications:write.named", "operations:complete", "organizations:create", "organizations:delete", "project:stand", "status:write", "users:create", "users:read.all", "users:read.named"];
|
|
14
14
|
/** A grant an operation declares as written. */
|
|
15
15
|
export type AppGrant = (typeof APP_GRANTS)[number];
|
|
16
16
|
/**
|
package/dist/app-contract.js
CHANGED
|
@@ -8,9 +8,9 @@ var file_buf_validate_validate = /* @__PURE__ */ fileDesc("ChtidWYvdmFsaWRhdGUvd
|
|
|
8
8
|
|
|
9
9
|
// ../proto-ts/src/apps/v1/apps_pb.js
|
|
10
10
|
import { file_google_protobuf_struct } from "@bufbuild/protobuf/wkt";
|
|
11
|
-
var file_apps_v1_apps = /* @__PURE__ */ fileDesc2("
|
|
11
|
+
var file_apps_v1_apps = /* @__PURE__ */ fileDesc2("ChJhcHBzL3YxL2FwcHMucHJvdG8SB2FwcHMudjEiwQUKCUFwcENvbmZpZxI0CgRuYW1lGAEgASgJQia6SCNyIRhAMh1eW2Etel1bYS16MC05XSooLVthLXowLTldKykqJBIYCgd2ZXJzaW9uGAIgASgJQge6SARyAhABEiMKCG1ldGFkYXRhGAMgASgLMhEuYXBwcy52MS5NZXRhZGF0YRInCgptaWRkbGV3YXJlGAQgASgLMhMuYXBwcy52MS5NaWRkbGV3YXJlEikKC2NyZWRlbnRpYWxzGAUgASgLMhQuYXBwcy52MS5DcmVkZW50aWFscxIwCg9zZXR0aW5nc19zY2hlbWEYBiABKAsyFy5nb29nbGUucHJvdG9idWYuU3RydWN0EjA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KHkZJRUxEX1NZTkNfRElSRUNUSU9OX1NJTktfT05MWRACEiYKIkZJRUxEX1NZTkNfRElSRUNUSU9OX0JJRElSRUNUSU9OQUwQAyqeAQoMU3RvcmFnZU93bmVyEh0KGVNUT1JBR0VfT1dORVJfVU5TUEVDSUZJRUQQABIZChVTVE9SQUdFX09XTkVSX1BST0pFQ1QQARIeChpTVE9SQUdFX09XTkVSX09SR0FOSVpBVElPThACEhYKElNUT1JBR0VfT1dORVJfVVNFUhAEIgQIAxADKhZTVE9SQUdFX09XTkVSX0NVU1RPTUVSQjVaM2dpdGh1Yi5jb20vZWlkZXN0dWRpby9mb2lyL2dlbi9wcm90by9hcHBzL3YxO2FwcHN2MWIGcHJvdG8z", [file_buf_validate_validate, file_google_protobuf_struct]);
|
|
12
12
|
var AppConfigSchema = /* @__PURE__ */ messageDesc2(file_apps_v1_apps, 0);
|
|
13
|
-
var
|
|
13
|
+
var UserSignInSchema = /* @__PURE__ */ messageDesc2(file_apps_v1_apps, 1);
|
|
14
14
|
var FeatureSchema = /* @__PURE__ */ messageDesc2(file_apps_v1_apps, 2);
|
|
15
15
|
var FeatureNotificationCategorySchema = /* @__PURE__ */ messageDesc2(file_apps_v1_apps, 3);
|
|
16
16
|
var FeatureConsentCategorySchema = /* @__PURE__ */ messageDesc2(file_apps_v1_apps, 4);
|
|
@@ -74,7 +74,6 @@ export {
|
|
|
74
74
|
CredentialsSchema,
|
|
75
75
|
Credentials_Strategy,
|
|
76
76
|
Credentials_StrategySchema,
|
|
77
|
-
CustomerSignInSchema,
|
|
78
77
|
DiscoveredAccountSchema,
|
|
79
78
|
DiscoveredCountSchema,
|
|
80
79
|
DiscoveredFieldGroupSchema,
|
|
@@ -116,6 +115,7 @@ export {
|
|
|
116
115
|
StorageOwnerSchema,
|
|
117
116
|
SuggestedFieldSchema,
|
|
118
117
|
UISchema,
|
|
118
|
+
UserSignInSchema,
|
|
119
119
|
WebhookSchema,
|
|
120
120
|
file_apps_v1_apps,
|
|
121
121
|
file_apps_v1_discovery
|
package/dist/app.js
CHANGED
|
@@ -138,8 +138,8 @@ var FoirAuthDowngradedError = class extends FoirRequestError {
|
|
|
138
138
|
downgrade;
|
|
139
139
|
constructor(downgrade) {
|
|
140
140
|
super(
|
|
141
|
-
`[foir] your
|
|
142
|
-
{ graphQLErrors: [{ message: "
|
|
141
|
+
`[foir] your user token was ${downgrade.userToken} (${downgrade.reason}), so the request was served as ${downgrade.servedAs}`,
|
|
142
|
+
{ graphQLErrors: [{ message: "user token rejected", extensions: { code: "AUTH_DOWNGRADED" } }] }
|
|
143
143
|
);
|
|
144
144
|
this.name = "FoirAuthDowngradedError";
|
|
145
145
|
this.downgrade = downgrade;
|
|
@@ -155,7 +155,7 @@ function reportAuthDowngrade(envelope) {
|
|
|
155
155
|
if (warnedDowngrade === downgrade.reason) return;
|
|
156
156
|
warnedDowngrade = downgrade.reason;
|
|
157
157
|
console.warn(
|
|
158
|
-
`[foir] your
|
|
158
|
+
`[foir] your user token was ${downgrade.userToken} (${downgrade.reason}) \u2014 this request was served as ${downgrade.servedAs}, so auth-targeted content resolved to its anonymous variant. ` + (downgrade.reason === "expired" ? "Re-exchange the token and retry." : "Check which credential you are sending.")
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
161
|
function refusePrunedDocument(json, options) {
|
|
@@ -244,18 +244,18 @@ function appLookupConflictOf(error) {
|
|
|
244
244
|
if (!keyBy.every((field) => typeof field === "string")) return null;
|
|
245
245
|
return { model, lookup, keyBy };
|
|
246
246
|
}
|
|
247
|
-
function
|
|
248
|
-
const unlinked = extensionOf(error, "
|
|
247
|
+
function appUserUnlinkedOf(error) {
|
|
248
|
+
const unlinked = extensionOf(error, "userUnlinked");
|
|
249
249
|
if (!unlinked) return null;
|
|
250
250
|
const { model, identityProvider } = unlinked;
|
|
251
251
|
if (typeof model !== "string" || typeof identityProvider !== "string") return null;
|
|
252
252
|
return { model, identityProvider };
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function userEmailUnavailableReasonOf(value) {
|
|
255
255
|
return typeof value === "string" && value !== "" ? value : null;
|
|
256
256
|
}
|
|
257
|
-
function
|
|
258
|
-
const reason =
|
|
257
|
+
function appUserEmailUnavailableOf(error) {
|
|
258
|
+
const reason = userEmailUnavailableReasonOf(extensionOf(error, "userEmailUnavailable")?.reason);
|
|
259
259
|
return reason ? { reason } : null;
|
|
260
260
|
}
|
|
261
261
|
function isAppFieldWithheld(error, field) {
|
|
@@ -286,13 +286,13 @@ function isSelectableFieldKey(fieldKey) {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
// src/app/client.ts
|
|
289
|
-
var
|
|
290
|
-
function isVerified(
|
|
291
|
-
return typeof
|
|
289
|
+
var USER_FIELDS = "id email status emailVerifiedAt";
|
|
290
|
+
function isVerified(user) {
|
|
291
|
+
return typeof user.emailVerifiedAt === "string" && user.emailVerifiedAt !== "";
|
|
292
292
|
}
|
|
293
|
-
function
|
|
294
|
-
if (!
|
|
295
|
-
return { id:
|
|
293
|
+
function userOf(user) {
|
|
294
|
+
if (!user?.id) return null;
|
|
295
|
+
return { id: user.id, email: user.email ?? "", verified: isVerified(user), status: user.status ?? "" };
|
|
296
296
|
}
|
|
297
297
|
var RECORD_ID_FIELD = "_id";
|
|
298
298
|
var RECORD_NATURAL_KEY_FIELD = "_naturalKey";
|
|
@@ -498,7 +498,7 @@ function createAppClient(config) {
|
|
|
498
498
|
"integrationConfig",
|
|
499
499
|
`query AppInstallConfig {
|
|
500
500
|
integrationConfig {
|
|
501
|
-
name enabled middlewareUrl targetModels webhookUrl config
|
|
501
|
+
name enabled middlewareUrl targetModels webhookUrl config userEmailUnavailable userSignIn
|
|
502
502
|
sources { key model naturalKey mode fields { appField modelField direction } }
|
|
503
503
|
sinks { key model naturalKey fields { appField modelField direction } }
|
|
504
504
|
}
|
|
@@ -515,8 +515,8 @@ function createAppClient(config) {
|
|
|
515
515
|
settings: got.config ?? {},
|
|
516
516
|
sources: bindingsOf(got.sources),
|
|
517
517
|
sinks: bindingsOf(got.sinks),
|
|
518
|
-
|
|
519
|
-
|
|
518
|
+
userEmailUnavailable: userEmailUnavailableReasonOf(got.userEmailUnavailable),
|
|
519
|
+
userSignIn: typeof got.userSignIn === "string" && got.userSignIn !== "" ? got.userSignIn : null
|
|
520
520
|
};
|
|
521
521
|
},
|
|
522
522
|
async credentials() {
|
|
@@ -670,10 +670,10 @@ function createAppClient(config) {
|
|
|
670
670
|
truncated: answer.truncated === true
|
|
671
671
|
};
|
|
672
672
|
},
|
|
673
|
-
|
|
673
|
+
user: {
|
|
674
674
|
async save(input) {
|
|
675
675
|
const { model, identity, data, email, sourceModifiedAt } = input;
|
|
676
|
-
if (identity === "") refuse(`a
|
|
676
|
+
if (identity === "") refuse(`a user's record on ${model} was saved with no identity`);
|
|
677
677
|
const variables = { modelKey: model, identity, data };
|
|
678
678
|
if (email !== void 0 && email !== "") variables.email = email;
|
|
679
679
|
const timed = sourceModifiedAt !== void 0;
|
|
@@ -681,17 +681,17 @@ function createAppClient(config) {
|
|
|
681
681
|
let answer;
|
|
682
682
|
try {
|
|
683
683
|
answer = await field(
|
|
684
|
-
"
|
|
685
|
-
timed ? `mutation
|
|
684
|
+
"saveUserRecord",
|
|
685
|
+
timed ? `mutation AppSaveUserRecord($modelKey: String!, $identity: String!, $email: String, $data: JSON!, $sourceModifiedAt: String) { saveUserRecord(modelKey: $modelKey, identity: $identity, email: $email, data: $data, sourceModifiedAt: $sourceModifiedAt) { record created userCreated stale } }` : `mutation AppSaveUserRecord($modelKey: String!, $identity: String!, $email: String, $data: JSON!) { saveUserRecord(modelKey: $modelKey, identity: $identity, email: $email, data: $data) { record created userCreated } }`,
|
|
686
686
|
variables
|
|
687
687
|
);
|
|
688
688
|
} catch (error) {
|
|
689
|
-
if (
|
|
689
|
+
if (appUserUnlinkedOf(error)) return { unlinked: true };
|
|
690
690
|
throw error;
|
|
691
691
|
}
|
|
692
692
|
const record = answer?.record;
|
|
693
693
|
if (!record || typeof record !== "object" || Array.isArray(record)) {
|
|
694
|
-
return refuse(`
|
|
694
|
+
return refuse(`saveUserRecord reported no error and returned no record on ${model}`);
|
|
695
695
|
}
|
|
696
696
|
return {
|
|
697
697
|
unlinked: false,
|
|
@@ -699,20 +699,20 @@ function createAppClient(config) {
|
|
|
699
699
|
id: recordIdOf(record),
|
|
700
700
|
created: answer?.created === true,
|
|
701
701
|
fieldsWithheld: record.fieldsWithheld === true,
|
|
702
|
-
|
|
702
|
+
userCreated: answer?.userCreated === true,
|
|
703
703
|
stale: answer?.stale === true
|
|
704
704
|
};
|
|
705
705
|
},
|
|
706
706
|
async read(model, identity) {
|
|
707
|
-
if (identity === "") refuse(`a
|
|
707
|
+
if (identity === "") refuse(`a user's record on ${model} was read with no identity`);
|
|
708
708
|
const record = await field(
|
|
709
|
-
"
|
|
710
|
-
`query
|
|
709
|
+
"userRecordByIdentity",
|
|
710
|
+
`query AppUserRecord($modelKey: String!, $identity: String!) { userRecordByIdentity(modelKey: $modelKey, identity: $identity) }`,
|
|
711
711
|
{ modelKey: model, identity }
|
|
712
712
|
);
|
|
713
713
|
if (!record) return null;
|
|
714
714
|
const id = recordIdOf(record);
|
|
715
|
-
if (!id) return refuse(`
|
|
715
|
+
if (!id) return refuse(`userRecordByIdentity answered a record with no id on ${model}`);
|
|
716
716
|
const data = record.data;
|
|
717
717
|
return {
|
|
718
718
|
id,
|
|
@@ -723,79 +723,79 @@ function createAppClient(config) {
|
|
|
723
723
|
};
|
|
724
724
|
},
|
|
725
725
|
async erase(model, identity) {
|
|
726
|
-
if (identity === "") refuse(`a
|
|
726
|
+
if (identity === "") refuse(`a user's record on ${model} was erased with no identity`);
|
|
727
727
|
const answer = await field(
|
|
728
|
-
"
|
|
729
|
-
`mutation
|
|
728
|
+
"eraseUserRecord",
|
|
729
|
+
`mutation AppEraseUserRecord($modelKey: String!, $identity: String!) { eraseUserRecord(modelKey: $modelKey, identity: $identity) { recordDeleted identityRemoved userDeleted userKeptBecause } }`,
|
|
730
730
|
{ modelKey: model, identity }
|
|
731
731
|
);
|
|
732
|
-
if (!answer) return refuse(`
|
|
732
|
+
if (!answer) return refuse(`eraseUserRecord reported no error and returned no answer on ${model}`);
|
|
733
733
|
return {
|
|
734
734
|
recordDeleted: answer.recordDeleted === true,
|
|
735
735
|
identityRemoved: answer.identityRemoved === true,
|
|
736
|
-
|
|
737
|
-
|
|
736
|
+
userDeleted: answer.userDeleted === true,
|
|
737
|
+
userKeptBecause: answer.userKeptBecause ?? null
|
|
738
738
|
};
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
741
|
},
|
|
742
|
-
|
|
742
|
+
users: {
|
|
743
743
|
async ensure(email) {
|
|
744
744
|
const address = email.trim();
|
|
745
|
-
if (address === "") refuse("a
|
|
746
|
-
const
|
|
747
|
-
"
|
|
748
|
-
`mutation
|
|
745
|
+
if (address === "") refuse("a user was asked for with an empty email");
|
|
746
|
+
const user = await field(
|
|
747
|
+
"createUser",
|
|
748
|
+
`mutation AppEnsureUser($input: CreateAuthUserInput!) { createUser(input: $input) { id email emailVerifiedAt } }`,
|
|
749
749
|
{ input: { email: address, returnExisting: true } }
|
|
750
750
|
);
|
|
751
|
-
if (!
|
|
752
|
-
return { id:
|
|
751
|
+
if (!user?.id) return refuse("createUser reported no error and returned no user");
|
|
752
|
+
return { id: user.id, email: user.email ?? address, verified: isVerified(user) };
|
|
753
753
|
},
|
|
754
754
|
async get(id) {
|
|
755
|
-
if (id.trim() === "") refuse("a
|
|
756
|
-
const
|
|
757
|
-
"
|
|
758
|
-
`query
|
|
755
|
+
if (id.trim() === "") refuse("a user was asked for with an empty id");
|
|
756
|
+
const user = await field(
|
|
757
|
+
"user",
|
|
758
|
+
`query AppUser($id: String) { user(id: $id) { ${USER_FIELDS} } }`,
|
|
759
759
|
{ id }
|
|
760
760
|
);
|
|
761
|
-
return
|
|
761
|
+
return userOf(user);
|
|
762
762
|
},
|
|
763
763
|
async byEmail(email) {
|
|
764
764
|
const address = email.trim();
|
|
765
|
-
if (address === "") refuse("a
|
|
766
|
-
const
|
|
767
|
-
"
|
|
768
|
-
`query
|
|
765
|
+
if (address === "") refuse("a user was asked for with an empty email");
|
|
766
|
+
const user = await field(
|
|
767
|
+
"user",
|
|
768
|
+
`query AppUserByEmail($email: String) { user(email: $email) { ${USER_FIELDS} } }`,
|
|
769
769
|
{ email: address }
|
|
770
770
|
);
|
|
771
|
-
return
|
|
771
|
+
return userOf(user);
|
|
772
772
|
},
|
|
773
773
|
async byIdentity(identity) {
|
|
774
|
-
if (identity === "") refuse("a
|
|
774
|
+
if (identity === "") refuse("a user was asked for with no identity");
|
|
775
775
|
const answer = await field(
|
|
776
|
-
"
|
|
777
|
-
`query
|
|
776
|
+
"userByIdentity",
|
|
777
|
+
`query AppUserByIdentity($identity: String!) { userByIdentity(identity: $identity) }`,
|
|
778
778
|
{ identity }
|
|
779
779
|
);
|
|
780
780
|
return typeof answer === "string" && answer !== "" ? answer : null;
|
|
781
781
|
},
|
|
782
|
-
async identities(
|
|
783
|
-
if (
|
|
782
|
+
async identities(userId) {
|
|
783
|
+
if (userId === "") refuse("a user's identities were asked for with no user");
|
|
784
784
|
const answer = await field(
|
|
785
|
-
"
|
|
786
|
-
`query
|
|
787
|
-
{
|
|
785
|
+
"userIdentitiesById",
|
|
786
|
+
`query AppUserIdentities($userId: ID!) { userIdentitiesById(userId: $userId) }`,
|
|
787
|
+
{ userId }
|
|
788
788
|
);
|
|
789
|
-
if (!Array.isArray(answer)) return refuse("
|
|
789
|
+
if (!Array.isArray(answer)) return refuse("userIdentitiesById reported no error and returned no list");
|
|
790
790
|
return answer.filter((identity) => typeof identity === "string");
|
|
791
791
|
},
|
|
792
792
|
async list(query = {}) {
|
|
793
793
|
const search = query.search?.trim() ?? "";
|
|
794
794
|
const page = await field(
|
|
795
|
-
"
|
|
796
|
-
`query
|
|
797
|
-
|
|
798
|
-
edges { node { ${
|
|
795
|
+
"users",
|
|
796
|
+
`query AppUsers($first: Int, $after: String, $filter: AuthUsersFilterInput) {
|
|
797
|
+
users(first: $first, after: $after, filter: $filter) {
|
|
798
|
+
edges { node { ${USER_FIELDS} } }
|
|
799
799
|
pageInfo { hasNextPage endCursor }
|
|
800
800
|
}
|
|
801
801
|
}`,
|
|
@@ -805,12 +805,12 @@ function createAppClient(config) {
|
|
|
805
805
|
...search !== "" ? { filter: { search } } : {}
|
|
806
806
|
}
|
|
807
807
|
);
|
|
808
|
-
const
|
|
808
|
+
const users = [];
|
|
809
809
|
for (const edge of page?.edges ?? []) {
|
|
810
|
-
const
|
|
811
|
-
if (
|
|
810
|
+
const user = userOf(edge?.node ?? null);
|
|
811
|
+
if (user) users.push(user);
|
|
812
812
|
}
|
|
813
|
-
return {
|
|
813
|
+
return { users, hasMore: page?.pageInfo?.hasNextPage === true, endCursor: page?.pageInfo?.endCursor ?? null };
|
|
814
814
|
}
|
|
815
815
|
},
|
|
816
816
|
organizations: {
|
|
@@ -826,9 +826,10 @@ function createAppClient(config) {
|
|
|
826
826
|
input.settings = { modelKey: settings.modelKey.trim(), data: settings.data };
|
|
827
827
|
}
|
|
828
828
|
if (organization.firstMember !== void 0) {
|
|
829
|
-
if (organization.firstMember.
|
|
830
|
-
input.firstMember = {
|
|
829
|
+
if (organization.firstMember.userId === "") return refuse("a first member names a user");
|
|
830
|
+
input.firstMember = { userId: organization.firstMember.userId };
|
|
831
831
|
}
|
|
832
|
+
if (organization.ownPool === true) input.ownPool = true;
|
|
832
833
|
const answered = settings === void 0 ? "organizationId status" : "organizationId settingsRecordId status";
|
|
833
834
|
const answer = await field(
|
|
834
835
|
"provisionOrganization",
|
|
@@ -856,10 +857,10 @@ function createAppClient(config) {
|
|
|
856
857
|
},
|
|
857
858
|
notifications: {
|
|
858
859
|
async send(notification) {
|
|
859
|
-
if (notification.
|
|
860
|
-
refuse("a notification needs a
|
|
860
|
+
if (notification.userId === "" || notification.title.trim() === "") {
|
|
861
|
+
refuse("a notification needs a user and a title");
|
|
861
862
|
}
|
|
862
|
-
const input = {
|
|
863
|
+
const input = { userId: notification.userId, title: notification.title };
|
|
863
864
|
if (notification.message !== void 0) input.message = notification.message;
|
|
864
865
|
if (notification.category !== void 0) input.category = notification.category;
|
|
865
866
|
if (notification.actionUrl !== void 0) input.actionUrl = notification.actionUrl;
|
|
@@ -880,8 +881,8 @@ function createAppClient(config) {
|
|
|
880
881
|
},
|
|
881
882
|
async setConsent(change) {
|
|
882
883
|
const subject = consentSubject(change);
|
|
883
|
-
if (subject === null) return refuse("a consent change names its
|
|
884
|
-
if (subject.value === "" || change.category === "") return refuse("a consent change needs a
|
|
884
|
+
if (subject === null) return refuse("a consent change names its user by userId or by email, not both");
|
|
885
|
+
if (subject.value === "" || change.category === "") return refuse("a consent change needs a user and a category");
|
|
885
886
|
const input = {
|
|
886
887
|
[subject.by]: subject.value,
|
|
887
888
|
category: change.category,
|
|
@@ -892,11 +893,11 @@ function createAppClient(config) {
|
|
|
892
893
|
if (change.givenElsewhere !== void 0) input.givenElsewhere = change.givenElsewhere;
|
|
893
894
|
if (change.locale !== void 0) input.locale = change.locale;
|
|
894
895
|
const answer = await field(
|
|
895
|
-
"
|
|
896
|
-
`mutation
|
|
896
|
+
"setUserConsent",
|
|
897
|
+
`mutation AppSetUserConsent($input: SetUserConsentInput!) { setUserConsent(input: $input) { stale confirmationPending } }`,
|
|
897
898
|
{ input }
|
|
898
899
|
);
|
|
899
|
-
if (!answer) return refuse("
|
|
900
|
+
if (!answer) return refuse("setUserConsent reported no error and answered nothing");
|
|
900
901
|
return { stale: answer.stale === true, confirmationPending: answer.confirmationPending === true };
|
|
901
902
|
}
|
|
902
903
|
},
|
|
@@ -934,9 +935,9 @@ function createAppClient(config) {
|
|
|
934
935
|
}
|
|
935
936
|
function consentSubject(change) {
|
|
936
937
|
const loose = change;
|
|
937
|
-
if (loose.email !== void 0 && loose.
|
|
938
|
+
if (loose.email !== void 0 && loose.userId !== void 0) return null;
|
|
938
939
|
if (loose.email !== void 0) return { by: "email", value: loose.email.trim() };
|
|
939
|
-
return { by: "
|
|
940
|
+
return { by: "userId", value: loose.userId ?? "" };
|
|
940
941
|
}
|
|
941
942
|
function directionOf(raw) {
|
|
942
943
|
const name = (raw ?? "").replace(/^FIELD_SYNC_DIRECTION_/, "");
|
|
@@ -1150,18 +1151,18 @@ var APP_HOOK_EVENTS = [
|
|
|
1150
1151
|
"RECORD_DELETED",
|
|
1151
1152
|
"RECORD_PUBLISHED",
|
|
1152
1153
|
"RECORD_UNPUBLISHED",
|
|
1153
|
-
"
|
|
1154
|
-
"
|
|
1155
|
-
"
|
|
1156
|
-
"
|
|
1154
|
+
"USER_CREATED",
|
|
1155
|
+
"USER_UPDATED",
|
|
1156
|
+
"USER_DELETED",
|
|
1157
|
+
"USER_MERGED",
|
|
1157
1158
|
"SESSION_REVOKED",
|
|
1158
1159
|
"OPERATION_COMPLETED",
|
|
1159
1160
|
"OPERATION_FAILED",
|
|
1160
1161
|
"OPERATION_CANCELLED",
|
|
1161
1162
|
"OPERATION_TIMED_OUT",
|
|
1162
|
-
"
|
|
1163
|
-
"
|
|
1164
|
-
"
|
|
1163
|
+
"MEMBERSHIP_GRANTED",
|
|
1164
|
+
"MEMBERSHIP_REVOKED",
|
|
1165
|
+
"MEMBERSHIP_ROLE_CHANGED",
|
|
1165
1166
|
"TENANT_PLAN_CHANGED",
|
|
1166
1167
|
"TENANT_SUBSCRIPTION_STATUS_CHANGED",
|
|
1167
1168
|
"PROJECT_CREATED",
|
|
@@ -1171,7 +1172,7 @@ var APP_HOOK_EVENTS = [
|
|
|
1171
1172
|
"MIGRATION_APPLIED",
|
|
1172
1173
|
"BULK_UPDATE_COMPLETED",
|
|
1173
1174
|
"BULK_PUBLISH_COMPLETED",
|
|
1174
|
-
"
|
|
1175
|
+
"USER_PREFERENCE_CHANGED",
|
|
1175
1176
|
"ORGANIZATION_CREATED",
|
|
1176
1177
|
"ORGANIZATION_UPDATED",
|
|
1177
1178
|
"ORGANIZATION_MOVED",
|
|
@@ -1205,6 +1206,7 @@ var APP_GRANTS = [
|
|
|
1205
1206
|
"operations:complete",
|
|
1206
1207
|
"organizations:create",
|
|
1207
1208
|
"organizations:delete",
|
|
1209
|
+
"project:stand",
|
|
1208
1210
|
"status:write",
|
|
1209
1211
|
"users:create",
|
|
1210
1212
|
"users:read.all",
|
|
@@ -1229,12 +1231,12 @@ export {
|
|
|
1229
1231
|
FoirRequestError,
|
|
1230
1232
|
MAX_APP_MANIFEST_BYTES,
|
|
1231
1233
|
RECORD_KEY_RULE,
|
|
1232
|
-
appCustomerEmailUnavailableOf,
|
|
1233
|
-
appCustomerUnlinkedOf,
|
|
1234
1234
|
appLookupConflictOf,
|
|
1235
1235
|
appModelFieldName,
|
|
1236
1236
|
appModelTypeName,
|
|
1237
1237
|
appSelectorEnumValue,
|
|
1238
|
+
appUserEmailUnavailableOf,
|
|
1239
|
+
appUserUnlinkedOf,
|
|
1238
1240
|
createAppClient,
|
|
1239
1241
|
isAppFieldWithheld,
|
|
1240
1242
|
readAppDispatch,
|