@jay-framework/wix-bookings 0.24.2 → 0.24.3

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.
@@ -0,0 +1,26 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import yaml from "js-yaml";
4
+ const CONFIG_FILE = ".wix-bookings.yaml";
5
+ const DEFAULTS = {
6
+ bookingAppId: "",
7
+ staffResourceTypeId: "",
8
+ slotWindowDays: 14,
9
+ postCheckoutUrl: "/"
10
+ };
11
+ function loadWixBookingsConfig(projectRoot) {
12
+ const configPath = path.join(projectRoot, "config", CONFIG_FILE);
13
+ if (!fs.existsSync(configPath)) {
14
+ return { ...DEFAULTS };
15
+ }
16
+ const raw = yaml.load(fs.readFileSync(configPath, "utf-8"));
17
+ return {
18
+ bookingAppId: raw.bookingAppId ?? DEFAULTS.bookingAppId,
19
+ staffResourceTypeId: raw.staffResourceTypeId ?? DEFAULTS.staffResourceTypeId,
20
+ slotWindowDays: raw.slotWindowDays ?? DEFAULTS.slotWindowDays,
21
+ postCheckoutUrl: raw.postCheckoutUrl ?? DEFAULTS.postCheckoutUrl
22
+ };
23
+ }
24
+ export {
25
+ loadWixBookingsConfig as l
26
+ };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import { W as WixBookingsService } from './index.client-CBlxQDjy.js';
2
2
  export { f as BookingFormFieldView, B as BookingServiceView, e as BookingSlotView, C as CreateBookingOutcome, d as WIX_BOOKINGS_SERVICE, b as bookingFlow, c as createBooking, i as init, l as listServices, a as listSlots } from './index.client-CBlxQDjy.js';
3
- import { PluginSetupContext, PluginSetupResult } from '@jay-framework/stack-server-runtime';
4
3
  import { WixClient } from '@wix/sdk';
5
4
  import '@jay-framework/fullstack-component';
6
5
  import '@jay-framework/component';
7
6
  import '@jay-framework/runtime';
8
7
 
9
- declare function setupWixBookings(ctx: PluginSetupContext): Promise<PluginSetupResult>;
10
- declare const setup: typeof setupWixBookings;
11
-
12
8
  interface WixBookingsConfig {
13
9
  bookingAppId: string;
14
10
  staffResourceTypeId: string;
@@ -18,4 +14,4 @@ interface WixBookingsConfig {
18
14
 
19
15
  declare function provideWixBookingsService(wixClient: WixClient, config: WixBookingsConfig): WixBookingsService;
20
16
 
21
- export { WixBookingsService, provideWixBookingsService, setup, setupWixBookings };
17
+ export { WixBookingsService, provideWixBookingsService };
package/dist/index.js CHANGED
@@ -1,30 +1,7 @@
1
1
  import { createJayService, makeJayInit, makeJayStackComponent, phaseOutput, RenderPipeline, makeJayQuery, makeJayAction } from "@jay-framework/fullstack-component";
2
- import { registerService, getService, hasService } from "@jay-framework/stack-server-runtime";
2
+ import { registerService, getService } from "@jay-framework/stack-server-runtime";
3
3
  import { wixFetch, WixApiError, WIX_CLIENT_SERVICE } from "@jay-framework/wix-server-client";
4
- import fs from "node:fs";
5
- import path from "node:path";
6
- import yaml from "js-yaml";
7
- import { WIX_FORMS_SERVICE } from "@jay-framework/wix-forms";
8
- const CONFIG_FILE$1 = ".wix-bookings.yaml";
9
- const DEFAULTS = {
10
- bookingAppId: "",
11
- staffResourceTypeId: "",
12
- slotWindowDays: 14,
13
- postCheckoutUrl: "/"
14
- };
15
- function loadWixBookingsConfig(projectRoot) {
16
- const configPath = path.join(projectRoot, "config", CONFIG_FILE$1);
17
- if (!fs.existsSync(configPath)) {
18
- return { ...DEFAULTS };
19
- }
20
- const raw = yaml.load(fs.readFileSync(configPath, "utf-8"));
21
- return {
22
- bookingAppId: raw.bookingAppId ?? DEFAULTS.bookingAppId,
23
- staffResourceTypeId: raw.staffResourceTypeId ?? DEFAULTS.staffResourceTypeId,
24
- slotWindowDays: raw.slotWindowDays ?? DEFAULTS.slotWindowDays,
25
- postCheckoutUrl: raw.postCheckoutUrl ?? DEFAULTS.postCheckoutUrl
26
- };
27
- }
4
+ import { l as loadWixBookingsConfig } from "./config-loader-C7I2yXpp.js";
28
5
  const MAX_SLOTS_PER_QUERY = 200;
29
6
  const SERVICES_PAGE_SIZE = 100;
30
7
  const WIX_BOOKINGS_SERVICE = createJayService("WixBookingsService");
@@ -381,62 +358,6 @@ const init = makeJayInit().withServer(async () => {
381
358
  console.log("[wix-bookings] Server initialization complete");
382
359
  return {};
383
360
  });
384
- const CONFIG_FILE = ".wix-bookings.yaml";
385
- const CONFIG_TEMPLATE = `# Wix Bookings Configuration
386
- #
387
- # bookingAppId — Wix Bookings app ID on your site
388
- bookingAppId: ""
389
-
390
- # staffResourceTypeId — resource type for staff selection (site-specific)
391
- staffResourceTypeId: ""
392
-
393
- slotWindowDays: 14
394
- postCheckoutUrl: "/book"
395
- `;
396
- async function setupWixBookings(ctx) {
397
- if (ctx.initError) {
398
- return {
399
- status: "error",
400
- message: `Service init failed (is wix-server-client configured?). ${ctx.initError.message}`
401
- };
402
- }
403
- if (!hasService(WIX_FORMS_SERVICE)) {
404
- return {
405
- status: "error",
406
- message: "wix-bookings requires the wix-forms plugin. Add wix-forms to your project plugins and run setup before wix-bookings."
407
- };
408
- }
409
- const configCreated = [];
410
- const configPath = path.join(ctx.configDir, CONFIG_FILE);
411
- if (!fs.existsSync(configPath)) {
412
- if (!fs.existsSync(ctx.configDir)) {
413
- fs.mkdirSync(ctx.configDir, { recursive: true });
414
- }
415
- fs.writeFileSync(configPath, CONFIG_TEMPLATE, "utf-8");
416
- configCreated.push(`config/${CONFIG_FILE}`);
417
- }
418
- const config = loadWixBookingsConfig(ctx.projectRoot);
419
- const missing = [];
420
- if (!config.bookingAppId) {
421
- missing.push("bookingAppId");
422
- }
423
- if (!config.staffResourceTypeId) {
424
- missing.push("staffResourceTypeId");
425
- }
426
- if (missing.length) {
427
- return {
428
- status: "needs-config",
429
- configCreated,
430
- message: `Set ${missing.join(", ")} in config/${CONFIG_FILE}`
431
- };
432
- }
433
- return {
434
- status: "configured",
435
- configCreated,
436
- message: `Wix Bookings configured (app: ${config.bookingAppId})`
437
- };
438
- }
439
- const setup = setupWixBookings;
440
361
  async function renderSlowlyChanging(_props, bookings) {
441
362
  try {
442
363
  const services = await bookings.listServices();
@@ -497,7 +418,5 @@ export {
497
418
  init,
498
419
  listServices,
499
420
  listSlots,
500
- provideWixBookingsService,
501
- setup,
502
- setupWixBookings
421
+ provideWixBookingsService
503
422
  };
@@ -0,0 +1,6 @@
1
+ import { PluginSetupContext, PluginSetupResult } from '@jay-framework/stack-server-runtime';
2
+
3
+ declare function setupWixBookings(ctx: PluginSetupContext): Promise<PluginSetupResult>;
4
+ declare const setup: typeof setupWixBookings;
5
+
6
+ export { setup, setupWixBookings };
package/dist/tools.js ADDED
@@ -0,0 +1,65 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { hasService } from "@jay-framework/stack-server-runtime";
4
+ import { WIX_FORMS_SERVICE } from "@jay-framework/wix-forms";
5
+ import { l as loadWixBookingsConfig } from "./config-loader-C7I2yXpp.js";
6
+ const CONFIG_FILE = ".wix-bookings.yaml";
7
+ const CONFIG_TEMPLATE = `# Wix Bookings Configuration
8
+ #
9
+ # bookingAppId — Wix Bookings app ID on your site
10
+ bookingAppId: ""
11
+
12
+ # staffResourceTypeId — resource type for staff selection (site-specific)
13
+ staffResourceTypeId: ""
14
+
15
+ slotWindowDays: 14
16
+ postCheckoutUrl: "/book"
17
+ `;
18
+ async function setupWixBookings(ctx) {
19
+ if (ctx.initError) {
20
+ return {
21
+ status: "error",
22
+ message: `Service init failed (is wix-server-client configured?). ${ctx.initError.message}`
23
+ };
24
+ }
25
+ if (!hasService(WIX_FORMS_SERVICE)) {
26
+ return {
27
+ status: "error",
28
+ message: "wix-bookings requires the wix-forms plugin. Add wix-forms to your project plugins and run setup before wix-bookings."
29
+ };
30
+ }
31
+ const configCreated = [];
32
+ const configPath = path.join(ctx.configDir, CONFIG_FILE);
33
+ if (!fs.existsSync(configPath)) {
34
+ if (!fs.existsSync(ctx.configDir)) {
35
+ fs.mkdirSync(ctx.configDir, { recursive: true });
36
+ }
37
+ fs.writeFileSync(configPath, CONFIG_TEMPLATE, "utf-8");
38
+ configCreated.push(`config/${CONFIG_FILE}`);
39
+ }
40
+ const config = loadWixBookingsConfig(ctx.projectRoot);
41
+ const missing = [];
42
+ if (!config.bookingAppId) {
43
+ missing.push("bookingAppId");
44
+ }
45
+ if (!config.staffResourceTypeId) {
46
+ missing.push("staffResourceTypeId");
47
+ }
48
+ if (missing.length) {
49
+ return {
50
+ status: "needs-config",
51
+ configCreated,
52
+ message: `Set ${missing.join(", ")} in config/${CONFIG_FILE}`
53
+ };
54
+ }
55
+ return {
56
+ status: "configured",
57
+ configCreated,
58
+ message: `Wix Bookings configured (app: ${config.bookingAppId})`
59
+ };
60
+ }
61
+ const setup = setupWixBookings;
62
+ export {
63
+ setup,
64
+ setupWixBookings
65
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/wix-bookings",
3
- "version": "0.24.2",
3
+ "version": "0.24.3",
4
4
  "type": "module",
5
5
  "description": "Wix Bookings package for Jay Framework — browse services, pick slots, submit participant details, complete checkout",
6
6
  "license": "Apache-2.0",
@@ -19,6 +19,7 @@
19
19
  "types": "./dist/index.client.d.ts",
20
20
  "default": "./dist/index.client.js"
21
21
  },
22
+ "./tools": "./dist/tools.js",
22
23
  "./plugin.yaml": "./plugin.yaml",
23
24
  "./booking-flow.jay-contract": "./dist/contracts/booking-flow.jay-contract",
24
25
  "./list-services.jay-action": "./dist/actions/list-services.jay-action",
@@ -32,22 +33,22 @@
32
33
  "build:client": "vite build",
33
34
  "build:server": "vite build --ssr",
34
35
  "build:copy-contract": "mkdir -p dist/contracts && cp lib/contracts/*.jay-contract* dist/contracts/ && mkdir -p dist/actions && cp lib/actions/*.jay-action dist/actions/",
35
- "build:types": "tsup lib/index.ts lib/index.client.ts --dts-only --format esm",
36
+ "build:types": "tsup lib/index.ts lib/index.client.ts lib/tools.ts --dts-only --format esm",
36
37
  "build:check-types": "tsc",
37
38
  "clean": "rimraf dist",
38
39
  "confirm": "npm run clean && npm run build && npm run test",
39
40
  "test": "vitest run"
40
41
  },
41
42
  "dependencies": {
42
- "@jay-framework/component": "^0.24.2",
43
- "@jay-framework/fullstack-component": "^0.24.2",
44
- "@jay-framework/reactive": "^0.24.2",
45
- "@jay-framework/runtime": "^0.24.2",
46
- "@jay-framework/secure": "^0.24.2",
47
- "@jay-framework/stack-client-runtime": "^0.24.2",
48
- "@jay-framework/stack-server-runtime": "^0.24.2",
49
- "@jay-framework/wix-forms": "^0.24.2",
50
- "@jay-framework/wix-server-client": "^0.24.2",
43
+ "@jay-framework/component": "^0.24.3",
44
+ "@jay-framework/fullstack-component": "^0.24.3",
45
+ "@jay-framework/reactive": "^0.24.3",
46
+ "@jay-framework/runtime": "^0.24.3",
47
+ "@jay-framework/secure": "^0.24.3",
48
+ "@jay-framework/stack-client-runtime": "^0.24.3",
49
+ "@jay-framework/stack-server-runtime": "^0.24.3",
50
+ "@jay-framework/wix-forms": "^0.24.3",
51
+ "@jay-framework/wix-server-client": "^0.24.3",
51
52
  "@wix/sdk": "^1.21.5",
52
53
  "js-yaml": "^4.1.0"
53
54
  },
@@ -55,10 +56,10 @@
55
56
  "@babel/core": "^7.23.7",
56
57
  "@babel/preset-env": "^7.23.8",
57
58
  "@babel/preset-typescript": "^7.23.3",
58
- "@jay-framework/compiler-jay-stack": "^0.24.2",
59
- "@jay-framework/jay-cli": "^0.24.2",
60
- "@jay-framework/jay-stack-cli": "^0.24.2",
61
- "@jay-framework/vite-plugin": "^0.24.2",
59
+ "@jay-framework/compiler-jay-stack": "^0.24.3",
60
+ "@jay-framework/jay-cli": "^0.24.3",
61
+ "@jay-framework/jay-stack-cli": "^0.24.3",
62
+ "@jay-framework/vite-plugin": "^0.24.3",
62
63
  "@jay-framework/wix-dev-environment": "^0.6.12",
63
64
  "nodemon": "^3.0.3",
64
65
  "rimraf": "^5.0.5",