@wix/create-headless-site 0.0.17 → 0.0.19

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/index.js CHANGED
@@ -95045,7 +95045,7 @@ function wixCliCliError(params) {
95045
95045
  var package_default = {
95046
95046
  name: "@wix/create-headless-site",
95047
95047
  description: "Headless site creation wizard",
95048
- version: "0.0.17",
95048
+ version: "0.0.19",
95049
95049
  bin: "bin/index.cjs",
95050
95050
  devDependencies: {
95051
95051
  "@commander-js/extra-typings": "^13.0.0",
@@ -102498,12 +102498,12 @@ var VersionType;
102498
102498
  VersionType2["DEV_VERSION"] = "DEV_VERSION";
102499
102499
  })(VersionType || (VersionType = {}));
102500
102500
  var WebhookIdentityType;
102501
- (function(WebhookIdentityType3) {
102502
- WebhookIdentityType3["UNKNOWN"] = "UNKNOWN";
102503
- WebhookIdentityType3["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
102504
- WebhookIdentityType3["MEMBER"] = "MEMBER";
102505
- WebhookIdentityType3["WIX_USER"] = "WIX_USER";
102506
- WebhookIdentityType3["APP"] = "APP";
102501
+ (function(WebhookIdentityType5) {
102502
+ WebhookIdentityType5["UNKNOWN"] = "UNKNOWN";
102503
+ WebhookIdentityType5["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
102504
+ WebhookIdentityType5["MEMBER"] = "MEMBER";
102505
+ WebhookIdentityType5["WIX_USER"] = "WIX_USER";
102506
+ WebhookIdentityType5["APP"] = "APP";
102507
102507
  })(WebhookIdentityType || (WebhookIdentityType = {}));
102508
102508
 
102509
102509
  // ../dev-center-client/src/schemas.ts
@@ -104996,12 +104996,12 @@ var TranslationType;
104996
104996
  TranslationType2["COMPONENT"] = "COMPONENT";
104997
104997
  })(TranslationType || (TranslationType = {}));
104998
104998
  var WebhookIdentityType2;
104999
- (function(WebhookIdentityType3) {
105000
- WebhookIdentityType3["UNKNOWN"] = "UNKNOWN";
105001
- WebhookIdentityType3["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
105002
- WebhookIdentityType3["MEMBER"] = "MEMBER";
105003
- WebhookIdentityType3["WIX_USER"] = "WIX_USER";
105004
- WebhookIdentityType3["APP"] = "APP";
104999
+ (function(WebhookIdentityType5) {
105000
+ WebhookIdentityType5["UNKNOWN"] = "UNKNOWN";
105001
+ WebhookIdentityType5["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
105002
+ WebhookIdentityType5["MEMBER"] = "MEMBER";
105003
+ WebhookIdentityType5["WIX_USER"] = "WIX_USER";
105004
+ WebhookIdentityType5["APP"] = "APP";
105005
105005
  })(WebhookIdentityType2 || (WebhookIdentityType2 = {}));
105006
105006
 
105007
105007
  // ../../node_modules/@wix/ambassador-devcenter-apps-v1-app-template/build/es/types.impl.js
@@ -105962,6 +105962,36 @@ function createAppProject(payload5) {
105962
105962
  return __createAppProject;
105963
105963
  }
105964
105964
 
105965
+ // ../../node_modules/@wix/ambassador-velo-backend-v1-app-project/build/es/types.impl.js
105966
+ init_esm_shims();
105967
+ var CustomDomainState;
105968
+ (function(CustomDomainState2) {
105969
+ CustomDomainState2["UNKNOWN_CUSTOM_DOMAIN_STATE"] = "UNKNOWN_CUSTOM_DOMAIN_STATE";
105970
+ CustomDomainState2["NOT_CONNECTED"] = "NOT_CONNECTED";
105971
+ CustomDomainState2["INITIATED"] = "INITIATED";
105972
+ CustomDomainState2["READY"] = "READY";
105973
+ CustomDomainState2["FAILED"] = "FAILED";
105974
+ })(CustomDomainState || (CustomDomainState = {}));
105975
+ var CloudProvider;
105976
+ (function(CloudProvider3) {
105977
+ CloudProvider3["UNKNOWN_CLOUD_PROVIDER"] = "UNKNOWN_CLOUD_PROVIDER";
105978
+ CloudProvider3["CLOUD_FLARE"] = "CLOUD_FLARE";
105979
+ CloudProvider3["KUBERNETES"] = "KUBERNETES";
105980
+ })(CloudProvider || (CloudProvider = {}));
105981
+ var SortOrder;
105982
+ (function(SortOrder3) {
105983
+ SortOrder3["ASC"] = "ASC";
105984
+ SortOrder3["DESC"] = "DESC";
105985
+ })(SortOrder || (SortOrder = {}));
105986
+ var WebhookIdentityType3;
105987
+ (function(WebhookIdentityType5) {
105988
+ WebhookIdentityType5["UNKNOWN"] = "UNKNOWN";
105989
+ WebhookIdentityType5["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
105990
+ WebhookIdentityType5["MEMBER"] = "MEMBER";
105991
+ WebhookIdentityType5["WIX_USER"] = "WIX_USER";
105992
+ WebhookIdentityType5["APP"] = "APP";
105993
+ })(WebhookIdentityType3 || (WebhookIdentityType3 = {}));
105994
+
105965
105995
  // ../../node_modules/@wix/ambassador-velo-backend-v1-app-environment/build/es/http.impl.js
105966
105996
  init_esm_shims();
105967
105997
  var _appEnvironment = {
@@ -106069,11 +106099,42 @@ function removeAppEnvironmentVariables(payload5) {
106069
106099
 
106070
106100
  // ../backend-as-a-service-client/src/schemas.ts
106071
106101
  init_esm_shims();
106102
+
106103
+ // ../../node_modules/@wix/ambassador-velo-backend-v1-app-deployment/build/es/types.impl.js
106104
+ init_esm_shims();
106105
+ var CloudProvider2;
106106
+ (function(CloudProvider3) {
106107
+ CloudProvider3["UNKNOWN_CLOUD_PROVIDER"] = "UNKNOWN_CLOUD_PROVIDER";
106108
+ CloudProvider3["CLOUD_FLARE"] = "CLOUD_FLARE";
106109
+ CloudProvider3["KUBERNETES"] = "KUBERNETES";
106110
+ })(CloudProvider2 || (CloudProvider2 = {}));
106111
+ var DeploymentState;
106112
+ (function(DeploymentState2) {
106113
+ DeploymentState2["UNKNOWN_DEPLOYMENT_STATE"] = "UNKNOWN_DEPLOYMENT_STATE";
106114
+ DeploymentState2["STATICS_UPLOAD_PENDING"] = "STATICS_UPLOAD_PENDING";
106115
+ DeploymentState2["DEPLOY_SUCCESS"] = "DEPLOY_SUCCESS";
106116
+ DeploymentState2["DEPLOY_FAILED"] = "DEPLOY_FAILED";
106117
+ })(DeploymentState || (DeploymentState = {}));
106118
+ var SortOrder2;
106119
+ (function(SortOrder3) {
106120
+ SortOrder3["ASC"] = "ASC";
106121
+ SortOrder3["DESC"] = "DESC";
106122
+ })(SortOrder2 || (SortOrder2 = {}));
106123
+ var WebhookIdentityType4;
106124
+ (function(WebhookIdentityType5) {
106125
+ WebhookIdentityType5["UNKNOWN"] = "UNKNOWN";
106126
+ WebhookIdentityType5["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
106127
+ WebhookIdentityType5["MEMBER"] = "MEMBER";
106128
+ WebhookIdentityType5["WIX_USER"] = "WIX_USER";
106129
+ WebhookIdentityType5["APP"] = "APP";
106130
+ })(WebhookIdentityType4 || (WebhookIdentityType4 = {}));
106131
+
106132
+ // ../backend-as-a-service-client/src/schemas.ts
106072
106133
  var staticFileMetadata = z.object({
106073
106134
  path: z.string(),
106074
106135
  hash: z.string(),
106075
106136
  size: z.number().optional(),
106076
- contentType: z.string().optional().nullable()
106137
+ contentType: z.string()
106077
106138
  });
106078
106139
  var StaticFileUploadUrlSchema = z.object({
106079
106140
  uploadUrl: z.string().url(),
@@ -106081,7 +106142,8 @@ var StaticFileUploadUrlSchema = z.object({
106081
106142
  });
106082
106143
  var AppDeploymentSchema = z.object({
106083
106144
  id: z.string().uuid(),
106084
- deploymentBaseUrl: z.string()
106145
+ deploymentBaseUrl: z.string(),
106146
+ cloudProviderOverride: z.nativeEnum(CloudProvider2)
106085
106147
  }).passthrough();
106086
106148
  var CompleteAppDeploymentSchema = z.object({
106087
106149
  appDeployment: AppDeploymentSchema
@@ -106101,7 +106163,7 @@ var CreateAppProjectSchema = z.object({
106101
106163
  });
106102
106164
  var CreateAppDeploymentSchema = z.object({
106103
106165
  staticFilesUploadUrls: z.array(StaticFileUploadUrlSchema).optional(),
106104
- uploadAuthToken: z.string(),
106166
+ uploadAuthToken: z.string().optional(),
106105
106167
  appDeployment: AppDeploymentSchema.optional()
106106
106168
  });
106107
106169
  var StaticFileUploadSchema = z.object({
@@ -106113,7 +106175,8 @@ var StaticFileUploadSchema = z.object({
106113
106175
 
106114
106176
  // ../backend-as-a-service-client/src/backend-as-a-service-client.ts
106115
106177
  var { minRetryTimeout: minRetryTimeout2 } = getTestOverrides();
106116
- var APP_PROJECT_TYPE_ID = "eb363dea-85a0-4159-9b05-949542be5079";
106178
+ var APP_PROJECT_TYPE_ID_CLOUDFLARE = "eb363dea-85a0-4159-9b05-949542be5079";
106179
+ var APP_PROJECT_TYPE_ID_KUBERNETES = "ad7b94c8-abc9-40f0-8be1-91dd7f3deb74";
106117
106180
  var BackendAsAServiceClient = class {
106118
106181
  constructor(httpClient) {
106119
106182
  this.httpClient = httpClient;
@@ -106124,7 +106187,7 @@ var BackendAsAServiceClient = class {
106124
106187
  };
106125
106188
  }
106126
106189
  retryOptions;
106127
- createAppProject = async (appId, projectName) => {
106190
+ createAppProject = async (appId, projectName, cloudProvider) => {
106128
106191
  try {
106129
106192
  const { data } = await this.httpClient.request(
106130
106193
  createAppProject({
@@ -106132,7 +106195,8 @@ var BackendAsAServiceClient = class {
106132
106195
  id: appId,
106133
106196
  displayName: projectName,
106134
106197
  slug: (0, import_lodash3.kebabCase)(projectName),
106135
- appProjectTypeId: APP_PROJECT_TYPE_ID
106198
+ appProjectTypeId: cloudProvider === CloudProvider.KUBERNETES ? APP_PROJECT_TYPE_ID_KUBERNETES : APP_PROJECT_TYPE_ID_CLOUDFLARE,
106199
+ cloudProviderOverride: cloudProvider
106136
106200
  }
106137
106201
  })
106138
106202
  );
@@ -106210,6 +106274,30 @@ var BackendAsAServiceClient = class {
106210
106274
  });
106211
106275
  }
106212
106276
  };
106277
+ putBinaryFile = async (endpointUrl, fileContent, contentType) => {
106278
+ try {
106279
+ await pRetry(
106280
+ async () => {
106281
+ const response = await fetch(endpointUrl, {
106282
+ method: "PUT",
106283
+ headers: {
106284
+ "Content-Type": contentType
106285
+ },
106286
+ body: fileContent
106287
+ });
106288
+ if (!response.ok) {
106289
+ throw new Error(response.statusText);
106290
+ }
106291
+ },
106292
+ { retries: 3 }
106293
+ );
106294
+ } catch (e2) {
106295
+ throw new CliError({
106296
+ code: CliErrorCode.FailedToUploadStaticFiles(),
106297
+ cause: e2
106298
+ });
106299
+ }
106300
+ };
106213
106301
  // Env management
106214
106302
  getAppEnvironmentByName = async (appId, environment) => {
106215
106303
  try {
@@ -106292,7 +106380,10 @@ var useCreateProject = (businessId) => {
106292
106380
  const { getInstalledAppInstanceId } = useMetasiteManagerClient();
106293
106381
  const { createAppProject: createAppProject2, upsertAppEnvironment: upsertAppEnvironment2 } = useBackendAsAServiceClient();
106294
106382
  return useAsyncCallback3(
106295
- async (_2, { projectName }) => {
106383
+ async (_2, {
106384
+ projectName,
106385
+ cloudProvider
106386
+ }) => {
106296
106387
  const { id: projectId } = await createOAuthApp2({
106297
106388
  name: `Private App for: ${projectName}`
106298
106389
  });
@@ -106300,7 +106391,11 @@ var useCreateProject = (businessId) => {
106300
106391
  getAppSecret({ appId: projectId }),
106301
106392
  getInstalledAppInstanceId({ metaSiteId: businessId, appId: projectId })
106302
106393
  ]);
106303
- const { appProject } = await createAppProject2(projectId, projectName);
106394
+ const { appProject } = await createAppProject2(
106395
+ projectId,
106396
+ projectName,
106397
+ cloudProvider
106398
+ );
106304
106399
  const loginRoute = `api/auth/callback`;
106305
106400
  const logoutRoute = `api/auth/logout-callback`;
106306
106401
  const projectBaseURL = new URL(appProject.baseUrl);
@@ -106345,7 +106440,12 @@ var useCreateProject = (businessId) => {
106345
106440
  };
106346
106441
 
106347
106442
  // src/components/CreateProject.tsx
106348
- var CreateProject = ({ onSubmit, projectName: providedProjectName, businessId }) => {
106443
+ var CreateProject = ({
106444
+ onSubmit,
106445
+ projectName: providedProjectName,
106446
+ businessId,
106447
+ cloudProvider
106448
+ }) => {
106349
106449
  const { status, execute } = useCreateProject(businessId);
106350
106450
  (0, import_react104.useEffect)(() => {
106351
106451
  if ((0, import_variant31.isType)(status, "Success")) {
@@ -106354,9 +106454,9 @@ var CreateProject = ({ onSubmit, projectName: providedProjectName, businessId })
106354
106454
  }, [status, onSubmit]);
106355
106455
  (0, import_react104.useEffect)(() => {
106356
106456
  if (providedProjectName) {
106357
- void execute({ projectName: providedProjectName });
106457
+ void execute({ projectName: providedProjectName, cloudProvider });
106358
106458
  }
106359
- }, [providedProjectName, execute]);
106459
+ }, [providedProjectName, cloudProvider, execute]);
106360
106460
  const validate3 = (0, import_react104.useCallback)(async (projectName) => {
106361
106461
  try {
106362
106462
  validateProjectName(projectName);
@@ -106369,7 +106469,7 @@ var CreateProject = ({ onSubmit, projectName: providedProjectName, businessId })
106369
106469
  TextInput2,
106370
106470
  {
106371
106471
  label: "What's the name of your Custom Frontend project?",
106372
- onSubmit: (projectName) => execute({ projectName }),
106472
+ onSubmit: (projectName) => execute({ projectName, cloudProvider }),
106373
106473
  validate: validate3,
106374
106474
  inCreateFlow: true
106375
106475
  }
@@ -116072,6 +116172,19 @@ function validateGitUrl(value2) {
116072
116172
  throw new InvalidArgumentError("Value must be a valid Git URL");
116073
116173
  }
116074
116174
 
116175
+ // src/validations/validate-cloud-provider.ts
116176
+ init_esm_shims();
116177
+ var validateCloudProvider = (value2) => {
116178
+ const allowedValues = ["cloudflare", "kubernetes"];
116179
+ const normalizedValue = value2.toLowerCase();
116180
+ if (!allowedValues.includes(normalizedValue)) {
116181
+ throw new Error(
116182
+ `Invalid cloud provider: ${value2}. Allowed values are: ${allowedValues.join(", ")}`
116183
+ );
116184
+ }
116185
+ return normalizedValue;
116186
+ };
116187
+
116075
116188
  // src/validations/validate-template-params.ts
116076
116189
  init_esm_shims();
116077
116190
  var schema2 = z.string().transform((value2) => JSON.parse(value2)).pipe(z.record(z.unknown()));
@@ -116792,6 +116905,24 @@ var TemplateSource = (0, import_variant37.variant)({
116792
116905
  GitRepo: (0, import_variant37.fields)(),
116793
116906
  Local: (0, import_variant37.fields)()
116794
116907
  });
116908
+ function parseCloudProvider(cloudProvider) {
116909
+ if (!cloudProvider) {
116910
+ return CloudProvider2.CLOUD_FLARE;
116911
+ }
116912
+ switch (cloudProvider.trim().toLowerCase()) {
116913
+ case "cloudflare":
116914
+ return CloudProvider2.CLOUD_FLARE;
116915
+ case "kubernetes":
116916
+ return CloudProvider2.KUBERNETES;
116917
+ default:
116918
+ throw new CliError({
116919
+ code: CliErrorCode.ProjectNameArgumentIsInvalid({
116920
+ errorMessage: `Invalid cloud provider: "${cloudProvider}".`
116921
+ }),
116922
+ cause: null
116923
+ });
116924
+ }
116925
+ }
116795
116926
  async function parseTemplateOptions(options) {
116796
116927
  if (options.siteTemplateId) {
116797
116928
  if (options.templateRepo && options.templateRepoPath) {
@@ -116870,6 +117001,7 @@ async function parseCommandOptions(targetParentFolder2, options) {
116870
117001
  targetParentFolder2,
116871
117002
  options
116872
117003
  );
117004
+ const cloudProvider = parseCloudProvider(options.cloudProvider);
116873
117005
  const publish = processPublish({
116874
117006
  template,
116875
117007
  projectName,
@@ -116888,6 +117020,7 @@ async function parseCommandOptions(targetParentFolder2, options) {
116888
117020
  template,
116889
117021
  projectName,
116890
117022
  businessName: options.businessName,
117023
+ cloudProvider,
116891
117024
  publish
116892
117025
  };
116893
117026
  }
@@ -117295,7 +117428,8 @@ var CreateHeadlessSiteCommand = ({
117295
117428
  template: defaultTemplate,
117296
117429
  publish,
117297
117430
  projectName: defaultProjectName,
117298
- businessName: defaultBusinessName
117431
+ businessName: defaultBusinessName,
117432
+ cloudProvider
117299
117433
  }) => {
117300
117434
  const [businessName, setBusinessName] = (0, import_react115.useState)(
117301
117435
  defaultBusinessName
@@ -117356,6 +117490,7 @@ var CreateHeadlessSiteCommand = ({
117356
117490
  {
117357
117491
  businessId,
117358
117492
  projectName: defaultProjectName,
117493
+ cloudProvider,
117359
117494
  onSubmit: (data) => setProjectData(data)
117360
117495
  }
117361
117496
  )),
@@ -117422,7 +117557,9 @@ var ProcessCommand = ({ targetParentFolder: targetParentFolder2, commandOptions
117422
117557
  return (0, import_variant43.match)(status, {
117423
117558
  Error: () => null,
117424
117559
  Loading: () => /* @__PURE__ */ import_react116.default.createElement(Spinner2, { text: "Loading..." }),
117425
- Success: ({ result: { template, projectName, businessName, publish } }) => {
117560
+ Success: ({
117561
+ result: { template, projectName, businessName, cloudProvider, publish }
117562
+ }) => {
117426
117563
  return /* @__PURE__ */ import_react116.default.createElement(
117427
117564
  CreateHeadlessSiteCommand,
117428
117565
  {
@@ -117431,6 +117568,7 @@ var ProcessCommand = ({ targetParentFolder: targetParentFolder2, commandOptions
117431
117568
  template,
117432
117569
  projectName,
117433
117570
  businessName,
117571
+ cloudProvider,
117434
117572
  publish
117435
117573
  }
117436
117574
  );
@@ -117540,6 +117678,11 @@ program2.command("init", { isDefault: true }).description("Create headless site"
117540
117678
  "--project-name <project-name>",
117541
117679
  "The name of your Custom Frontend project"
117542
117680
  ).argParser(validateProjectName).hideHelp()
117681
+ ).addOption(
117682
+ new Option(
117683
+ "--cloud-provider <cloud-provider>",
117684
+ "Cloud provider for deployment"
117685
+ ).argParser(validateCloudProvider).hideHelp()
117543
117686
  ).addOption(
117544
117687
  new Option(
117545
117688
  "--publish",