@wirechunk/cli 0.0.4 → 0.0.5

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/build/main.js CHANGED
@@ -3957,8 +3957,6 @@ const normalizeEmailAddress = (email) => {
3957
3957
  };
3958
3958
  const siteDomainKey = "siteDomain";
3959
3959
  const submittedAtKey = "submittedAt";
3960
- const defaultFormattedDataTemplate = `{{#each .}}{{@key}}: {{{.}}}
3961
- {{/each}}`;
3962
3960
  const defaultNotificationEmailBodyTemplate = `Form entry from your site {{${siteDomainKey}}}:
3963
3961
 
3964
3962
  {{#each .}}{{@key}}: {{{.}}}
@@ -24958,9 +24956,22 @@ const bootstrap = async (opts, env2) => {
24958
24956
  }
24959
24957
  await db.transaction(async (db2) => {
24960
24958
  await db2.query(
24961
- distExports$1.sql.type(
24962
- voidSelectSchema
24963
- )`insert into "Platforms" ("id", "handle", "name", "defaultFormFormattedDataTemplate", "defaultFormNotificationEmailBodyTemplate", "emailSendFromAddress") values (${platformId}, ${handle}, ${name}, ${defaultFormattedDataTemplate}, ${defaultNotificationEmailBodyTemplate}, ${emailSendFrom})`
24959
+ distExports$1.sql.type(voidSelectSchema)`
24960
+ insert into "Platforms" (
24961
+ "id",
24962
+ "handle",
24963
+ "name",
24964
+ "defaultFormNotificationEmailBodyTemplate",
24965
+ "emailSendFromAddress"
24966
+ )
24967
+ values (
24968
+ ${platformId},
24969
+ ${handle},
24970
+ ${name},
24971
+ ${defaultNotificationEmailBodyTemplate},
24972
+ ${emailSendFrom}
24973
+ )
24974
+ `
24964
24975
  );
24965
24976
  });
24966
24977
  console.log(`Created platform ${name} with handle ${handle} (ID ${platformId})`);
@@ -25113,6 +25124,7 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
25113
25124
  return false;
25114
25125
  } else {
25115
25126
  if (data6.path !== void 0) {
25127
+ const _errs16 = errors2;
25116
25128
  if (typeof data6.path !== "string") {
25117
25129
  validate25.errors = [
25118
25130
  {
@@ -25125,6 +25137,67 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
25125
25137
  ];
25126
25138
  return false;
25127
25139
  }
25140
+ var valid4 = _errs16 === errors2;
25141
+ } else {
25142
+ var valid4 = true;
25143
+ }
25144
+ if (valid4) {
25145
+ if (data6.description !== void 0) {
25146
+ const _errs18 = errors2;
25147
+ if (typeof data6.description !== "string") {
25148
+ validate25.errors = [
25149
+ {
25150
+ instancePath: instancePath + "/components/" + key0.replace(/~/g, "~0").replace(/\//g, "~1") + "/description",
25151
+ schemaPath: "#/properties/components/additionalProperties/properties/description/type",
25152
+ keyword: "type",
25153
+ params: { type: "string" },
25154
+ message: "must be string"
25155
+ }
25156
+ ];
25157
+ return false;
25158
+ }
25159
+ var valid4 = _errs18 === errors2;
25160
+ } else {
25161
+ var valid4 = true;
25162
+ }
25163
+ if (valid4) {
25164
+ if (data6.supports !== void 0) {
25165
+ let data9 = data6.supports;
25166
+ const _errs20 = errors2;
25167
+ {
25168
+ if (data9 && typeof data9 == "object" && !Array.isArray(data9)) {
25169
+ if (data9.children !== void 0) {
25170
+ if (typeof data9.children !== "boolean") {
25171
+ validate25.errors = [
25172
+ {
25173
+ instancePath: instancePath + "/components/" + key0.replace(/~/g, "~0").replace(/\//g, "~1") + "/supports/children",
25174
+ schemaPath: "#/properties/components/additionalProperties/properties/supports/properties/children/type",
25175
+ keyword: "type",
25176
+ params: { type: "boolean" },
25177
+ message: "must be boolean"
25178
+ }
25179
+ ];
25180
+ return false;
25181
+ }
25182
+ }
25183
+ } else {
25184
+ validate25.errors = [
25185
+ {
25186
+ instancePath: instancePath + "/components/" + key0.replace(/~/g, "~0").replace(/\//g, "~1") + "/supports",
25187
+ schemaPath: "#/properties/components/additionalProperties/properties/supports/type",
25188
+ keyword: "type",
25189
+ params: { type: "object" },
25190
+ message: "must be object"
25191
+ }
25192
+ ];
25193
+ return false;
25194
+ }
25195
+ }
25196
+ var valid4 = _errs20 === errors2;
25197
+ } else {
25198
+ var valid4 = true;
25199
+ }
25200
+ }
25128
25201
  }
25129
25202
  }
25130
25203
  } else {
@@ -61089,6 +61162,10 @@ const permissionUserEditProfile = {
61089
61162
  object: "User",
61090
61163
  action: "editProfile"
61091
61164
  };
61165
+ const permissionUserEditCustomFields = {
61166
+ object: "User",
61167
+ action: "editCustomFields"
61168
+ };
61092
61169
  const permissionFormTemplateSync = {
61093
61170
  object: "FormTemplate",
61094
61171
  action: "sync"
@@ -61144,6 +61221,7 @@ const allPermissions = [
61144
61221
  permissionUserEditStatus,
61145
61222
  permissionUserEditRole,
61146
61223
  permissionUserEditProfile,
61224
+ permissionUserEditCustomFields,
61147
61225
  permissionFormTemplateSync,
61148
61226
  permissionPageTemplateSync,
61149
61227
  permissionPlatformView,
@@ -61346,13 +61424,13 @@ const initExtDb = async ({
61346
61424
  create foreign table if not exists "Orgs" (
61347
61425
  "id" text not null,
61348
61426
  "name" text,
61349
- "primaryUserId" text,
61427
+ "primaryUserId" uuid,
61350
61428
  "createdAt" timestamptz not null
61351
61429
  ) server wirechunk options (schema_name 'public', table_name 'Orgs')
61352
61430
  `);
61353
61431
  await db.query(distExports$1.sql.unsafe`
61354
61432
  create foreign table if not exists "Sites" (
61355
- "id" uuid not null,
61433
+ "id" text not null,
61356
61434
  "domain" text not null,
61357
61435
  "orgId" text,
61358
61436
  "name" text not null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirechunk/cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -2,10 +2,7 @@ import { randomUUID } from 'node:crypto';
2
2
  import { cleanTinyId } from '@wirechunk/lib/clean-small-id.ts';
3
3
  import { normalizeDomain } from '@wirechunk/lib/domains.ts';
4
4
  import { normalizeEmailAddress } from '@wirechunk/lib/emails.ts';
5
- import {
6
- defaultFormattedDataTemplate,
7
- defaultNotificationEmailBodyTemplate,
8
- } from '@wirechunk/lib/mixer/form-formatting-templates.ts';
5
+ import { defaultNotificationEmailBodyTemplate } from '@wirechunk/lib/mixer/form-formatting-templates.ts';
9
6
  import type { DatabasePool } from 'slonik';
10
7
  import { createPool, sql } from 'slonik';
11
8
  import type { Env } from '../env.ts';
@@ -65,9 +62,22 @@ export const bootstrap = async (
65
62
 
66
63
  await db.transaction(async (db) => {
67
64
  await db.query(
68
- sql.type(
69
- voidSelectSchema,
70
- )`insert into "Platforms" ("id", "handle", "name", "defaultFormFormattedDataTemplate", "defaultFormNotificationEmailBodyTemplate", "emailSendFromAddress") values (${platformId}, ${handle}, ${name}, ${defaultFormattedDataTemplate}, ${defaultNotificationEmailBodyTemplate}, ${emailSendFrom})`,
65
+ sql.type(voidSelectSchema)`
66
+ insert into "Platforms" (
67
+ "id",
68
+ "handle",
69
+ "name",
70
+ "defaultFormNotificationEmailBodyTemplate",
71
+ "emailSendFromAddress"
72
+ )
73
+ values (
74
+ ${platformId},
75
+ ${handle},
76
+ ${name},
77
+ ${defaultNotificationEmailBodyTemplate},
78
+ ${emailSendFrom}
79
+ )
80
+ `,
71
81
  );
72
82
  });
73
83
 
@@ -59,13 +59,13 @@ const initExtDb = async ({
59
59
  create foreign table if not exists "Orgs" (
60
60
  "id" text not null,
61
61
  "name" text,
62
- "primaryUserId" text,
62
+ "primaryUserId" uuid,
63
63
  "createdAt" timestamptz not null
64
64
  ) server wirechunk options (schema_name 'public', table_name 'Orgs')
65
65
  `);
66
66
  await db.query(sql.unsafe`
67
67
  create foreign table if not exists "Sites" (
68
- "id" uuid not null,
68
+ "id" text not null,
69
69
  "domain" text not null,
70
70
  "orgId" text,
71
71
  "name" text not null,
@@ -76,11 +76,7 @@ export type AddressInput = {
76
76
  state: Scalars['String']['input'];
77
77
  };
78
78
 
79
- /**
80
- * An admin user is a subset of a User. This type is used when the host platform does not have a site and orgs
81
- * like normal platforms and instead the admin dashboard is displayed on a configured domain where admin users
82
- * can sign in (in this case features that require a site and orgs are not available).
83
- */
79
+ /** A user who could be an admin on platforms. */
84
80
  export type AdminUser = {
85
81
  __typename?: 'AdminUser';
86
82
  apiTokens: PersonalApiTokensList;
@@ -90,6 +86,7 @@ export type AdminUser = {
90
86
  firstName: Scalars['String']['output'];
91
87
  id: Scalars['String']['output'];
92
88
  lastName: Scalars['String']['output'];
89
+ /** This user’s platforms where the user is an admin (possible inactive). */
93
90
  platformAdminUsers: Array<PlatformAdminUser>;
94
91
  };
95
92
 
@@ -314,6 +311,7 @@ export type CreateCourseSuccessResult = {
314
311
  export type CreateCustomTableEditorFormVersionInput = {
315
312
  components: Scalars['String']['input'];
316
313
  customTableId: Scalars['String']['input'];
314
+ setAsCurrent?: Scalars['Boolean']['input'];
317
315
  };
318
316
 
319
317
  export type CreateCustomTableEditorFormVersionResult =
@@ -323,6 +321,7 @@ export type CreateCustomTableEditorFormVersionResult =
323
321
 
324
322
  export type CreateCustomTableEditorFormVersionSuccessResult = {
325
323
  __typename?: 'CreateCustomTableEditorFormVersionSuccessResult';
324
+ customTable: CustomTable;
326
325
  customTableEditorFormVersion: CustomTableEditorFormVersion;
327
326
  };
328
327
 
@@ -456,6 +455,19 @@ export type CreatePlatformApiTokenSuccessResult = {
456
455
  token: Scalars['String']['output'];
457
456
  };
458
457
 
458
+ export type CreatePlatformInput = {
459
+ handle: Scalars['String']['input'];
460
+ mainSiteDomain?: InputMaybe<Scalars['String']['input']>;
461
+ name: Scalars['String']['input'];
462
+ };
463
+
464
+ export type CreatePlatformResult = CreatePlatformSuccessResult | UserError;
465
+
466
+ export type CreatePlatformSuccessResult = {
467
+ __typename?: 'CreatePlatformSuccessResult';
468
+ platform: Platform;
469
+ };
470
+
459
471
  export type CreateProductResult = CreateProductSuccessResult | UserError;
460
472
 
461
473
  export type CreateProductSuccessResult = {
@@ -1201,6 +1213,7 @@ export type EditUserInput = {
1201
1213
  customFields?: InputMaybe<Array<KeyValueInput>>;
1202
1214
  expiresAt?: InputMaybe<OptionalDateUpdate>;
1203
1215
  id: Scalars['String']['input'];
1216
+ status?: InputMaybe<UserStatusUpdate>;
1204
1217
  };
1205
1218
 
1206
1219
  export type EditUserResult = EditUserSuccessResult | UserError;
@@ -1445,6 +1458,19 @@ export const GCloudCertificateState = {
1445
1458
 
1446
1459
  export type GCloudCertificateState =
1447
1460
  (typeof GCloudCertificateState)[keyof typeof GCloudCertificateState];
1461
+ export type GenerateComponentsInput = {
1462
+ platformId: Scalars['String']['input'];
1463
+ prompt: Scalars['String']['input'];
1464
+ startingComponents: Scalars['String']['input'];
1465
+ };
1466
+
1467
+ export type GenerateComponentsResult = GenerateComponentsSuccessResult | InternalError | UserError;
1468
+
1469
+ export type GenerateComponentsSuccessResult = {
1470
+ __typename?: 'GenerateComponentsSuccessResult';
1471
+ components: Scalars['String']['output'];
1472
+ };
1473
+
1448
1474
  export type HelpTicket = {
1449
1475
  __typename?: 'HelpTicket';
1450
1476
  createdAt: Scalars['Date']['output'];
@@ -1719,6 +1745,7 @@ export type Mutation = {
1719
1745
  createPageFromTemplate: Page;
1720
1746
  createPageTemplate: PageTemplate;
1721
1747
  createPersonalApiToken: CreatePersonalApiTokenResult;
1748
+ createPlatform: CreatePlatformResult;
1722
1749
  createPlatformApiToken: CreatePlatformApiTokenResult;
1723
1750
  createProduct: CreateProductResult;
1724
1751
  createSequence: CreateSequenceResult;
@@ -1813,11 +1840,13 @@ export type Mutation = {
1813
1840
  editUserName: User;
1814
1841
  editUserPlan: UserPlan;
1815
1842
  editUserRole: User;
1843
+ /** @deprecated Use editUser instead. */
1816
1844
  editUserStatus: User;
1817
1845
  /** Finds or creates a Stripe customer for the current user. */
1818
1846
  findOrCreateStripeCustomer: StripeCustomer;
1819
1847
  /** Finds or creates a Stripe subscription for the current user. An existing subscription is returned only if it is active. */
1820
1848
  findOrCreateStripeSubscription: FindOrCreateStripeSubscriptionResult;
1849
+ generateComponents: GenerateComponentsResult;
1821
1850
  invalidateApiToken: InvalidateApiTokenResult;
1822
1851
  moveUserToOrg: MoveUserToOrgResult;
1823
1852
  refreshSession: Scalars['Boolean']['output'];
@@ -1970,6 +1999,10 @@ export type MutationCreatePersonalApiTokenArgs = {
1970
1999
  input: CreatePersonalApiTokenInput;
1971
2000
  };
1972
2001
 
2002
+ export type MutationCreatePlatformArgs = {
2003
+ input: CreatePlatformInput;
2004
+ };
2005
+
1973
2006
  export type MutationCreatePlatformApiTokenArgs = {
1974
2007
  input: CreatePlatformApiTokenInput;
1975
2008
  };
@@ -2438,6 +2471,10 @@ export type MutationFindOrCreateStripeSubscriptionArgs = {
2438
2471
  subscriptionPlanId: Scalars['String']['input'];
2439
2472
  };
2440
2473
 
2474
+ export type MutationGenerateComponentsArgs = {
2475
+ input: GenerateComponentsInput;
2476
+ };
2477
+
2441
2478
  export type MutationInvalidateApiTokenArgs = {
2442
2479
  id: Scalars['String']['input'];
2443
2480
  };
@@ -2822,6 +2859,8 @@ export const PermissionName = {
2822
2859
  EditSubscription: 'EditSubscription',
2823
2860
  /** Edit any page and form template. */
2824
2861
  EditTemplate: 'EditTemplate',
2862
+ /** Edit any custom field of any user. */
2863
+ EditUserCustomFields: 'EditUserCustomFields',
2825
2864
  /** Edit any user's email address. */
2826
2865
  EditUserEmail: 'EditUserEmail',
2827
2866
  /** Edit which org any user is in and whether a user is an org owner. */
@@ -3125,6 +3164,7 @@ export type PublishStatusUpdate = {
3125
3164
 
3126
3165
  export type Query = {
3127
3166
  __typename?: 'Query';
3167
+ adminMe?: Maybe<AdminUser>;
3128
3168
  applyCustomPromoCode: ApplyCustomPromoCodeResult;
3129
3169
  /**
3130
3170
  * Get active components that can be used for the visual builder on a platform. Results include built-in,
@@ -3135,6 +3175,7 @@ export type Query = {
3135
3175
  components: ComponentsList;
3136
3176
  course: Course;
3137
3177
  courses: CoursesList;
3178
+ customTable?: Maybe<CustomTable>;
3138
3179
  customTables: CustomTablesList;
3139
3180
  document: Document;
3140
3181
  documentDownloadPrompts: Array<DocumentDownloadPrompt>;
@@ -3151,7 +3192,6 @@ export type Query = {
3151
3192
  * help tickets are returned (and platformId needs to be the user’s own platform ID).
3152
3193
  */
3153
3194
  helpTickets: HelpTicketsList;
3154
- helpTickets2: HelpTicketsList;
3155
3195
  /**
3156
3196
  * Get an object with the form data with which to initialize the specified form. The result factors
3157
3197
  * in the signed in user, if any. The request needs to be sent to the API endpoint of the site on
@@ -3164,7 +3204,6 @@ export type Query = {
3164
3204
  lesson: Lesson;
3165
3205
  liveCustomFields: Array<CustomField>;
3166
3206
  me?: Maybe<User>;
3167
- me2?: Maybe<Me>;
3168
3207
  /** TODO: This should also take a productId to filter on. */
3169
3208
  multiOrgView: Array<Org>;
3170
3209
  organization: Org;
@@ -3235,6 +3274,11 @@ export type QueryCoursesArgs = {
3235
3274
  platformId: Scalars['String']['input'];
3236
3275
  };
3237
3276
 
3277
+ export type QueryCustomTableArgs = {
3278
+ object: CustomTableObject;
3279
+ platformId: Scalars['String']['input'];
3280
+ };
3281
+
3238
3282
  export type QueryCustomTablesArgs = {
3239
3283
  limit?: InputMaybe<Scalars['Int']['input']>;
3240
3284
  object?: InputMaybe<CustomTableObject>;
@@ -3296,12 +3340,6 @@ export type QueryHelpTicketsArgs = {
3296
3340
  platformId: Scalars['String']['input'];
3297
3341
  };
3298
3342
 
3299
- export type QueryHelpTickets2Args = {
3300
- limit?: Scalars['Int']['input'];
3301
- page?: Scalars['Int']['input'];
3302
- platformId: Scalars['String']['input'];
3303
- };
3304
-
3305
3343
  export type QueryInitialFormDataArgs = {
3306
3344
  formId: Scalars['String']['input'];
3307
3345
  pageId?: InputMaybe<Scalars['String']['input']>;
@@ -3520,6 +3558,7 @@ export type RemoteComponent = {
3520
3558
  id: Scalars['String']['output'];
3521
3559
  name: Scalars['String']['output'];
3522
3560
  stylesheetUrls: Array<Scalars['String']['output']>;
3561
+ supportsChildren: Scalars['Boolean']['output'];
3523
3562
  url: Scalars['String']['output'];
3524
3563
  };
3525
3564
 
@@ -3656,6 +3695,7 @@ export type Site = {
3656
3695
  agentPhotoUrl?: Maybe<Scalars['String']['output']>;
3657
3696
  agreements: AgreementsList;
3658
3697
  bodyEndCode?: Maybe<Scalars['String']['output']>;
3698
+ custom: CustomFieldValuesList;
3659
3699
  domain: Scalars['String']['output'];
3660
3700
  fontFamily: Scalars['String']['output'];
3661
3701
  globalCss?: Maybe<Scalars['String']['output']>;
@@ -4128,7 +4168,10 @@ export type User = {
4128
4168
  passwordStatus: PasswordStatus;
4129
4169
  planProgress: Array<UserPlanProgress>;
4130
4170
  plans: Array<UserPlan>;
4131
- /** This user’s platforms where the user is an admin. */
4171
+ /**
4172
+ * This user’s platforms where the user is an admin.
4173
+ * @deprecated Use adminMe instead.
4174
+ */
4132
4175
  platformAdminUsers: Array<PlatformAdminUser>;
4133
4176
  /** All product items from all of the active subscriptions of the user's org. */
4134
4177
  productItems: Array<Scalars['String']['output']>;
@@ -4255,6 +4298,10 @@ export const UserStatus = {
4255
4298
  } as const;
4256
4299
 
4257
4300
  export type UserStatus = (typeof UserStatus)[keyof typeof UserStatus];
4301
+ export type UserStatusUpdate = {
4302
+ value: UserStatus;
4303
+ };
4304
+
4258
4305
  export type UsersList = ListResult & {
4259
4306
  __typename?: 'UsersList';
4260
4307
  limit: Scalars['Int']['output'];