@jay-framework/wix-deploy 0.22.0 → 0.23.1
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/agent-kit/devops/wix-baas-deployment.md +168 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +305 -6616
- package/package.json +10 -11
- package/plugin.yaml +5 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Deploying to Wix BaaS
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The `wix-deploy` plugin deploys Jay Framework apps to Wix BaaS (serverless). It bundles the server code into a single `entry.mjs`, uploads page data to a Wix data collection, and deploys to BaaS + CDN.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run build:production # build frontend + backend
|
|
9
|
+
npm run deploy # bundle + upload + deploy
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Setup (First Time)
|
|
13
|
+
|
|
14
|
+
### 1. Create the Wix headless site
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm create @wix/new@latest init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Creates `wix.config.json` with `appId` and `siteId`. This is the **deployment target** — the BaaS worker and CDN assets go here.
|
|
21
|
+
|
|
22
|
+
### 2. Add Wix applications
|
|
23
|
+
|
|
24
|
+
In the Wix Business Manager, add the applications your project needs (e.g., Wix Stores, Wix Data). This is done on the **backend services site** — which may be the same site as the deployment target, or a different one in a headless setup.
|
|
25
|
+
|
|
26
|
+
### 3. Create an API key
|
|
27
|
+
|
|
28
|
+
In the Wix dashboard (API Keys section), create an API key with permissions for:
|
|
29
|
+
- Wix Data (read/write) — for the backend files data collection
|
|
30
|
+
- Any APIs your app uses (Stores, CMS, etc.)
|
|
31
|
+
|
|
32
|
+
### 4. Configure credentials
|
|
33
|
+
|
|
34
|
+
Add the API key to `config/.wix.yaml`. Running `jay-stack-cli setup` will fill in `clientId` and `siteId` from `wix.config.json` automatically — you only need to add the API key.
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
apiKeyStrategy:
|
|
38
|
+
apiKey: <your-api-key>
|
|
39
|
+
siteId: <auto-filled-from-wix-config>
|
|
40
|
+
oauthStrategy:
|
|
41
|
+
clientId: <auto-filled-from-wix-config>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 5. Authenticate with Wix CLI
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
wix login
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Stores OAuth tokens in `~/.wix/auth/`. The deploy command refreshes expired tokens automatically.
|
|
51
|
+
|
|
52
|
+
### 6. Create the data collection
|
|
53
|
+
|
|
54
|
+
Create a collection named `jay-backend-files` in the Wix dashboard (on the business site, where `.wix.yaml` points). Required fields:
|
|
55
|
+
|
|
56
|
+
| Field | Type | Description |
|
|
57
|
+
|-------|------|-------------|
|
|
58
|
+
| `path` | Text | Relative file path |
|
|
59
|
+
| `content` | Text | File content |
|
|
60
|
+
| `fileType` | Text | File extension |
|
|
61
|
+
| `sizeBytes` | Number | Content byte length |
|
|
62
|
+
| `category` | Text | `eager` or `lazy` |
|
|
63
|
+
| `version` | Text | Build version (semver) |
|
|
64
|
+
|
|
65
|
+
### 7. Validate setup
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
jay-stack-cli setup
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Should show all three plugins as configured:
|
|
72
|
+
- `wix-server-client` — credentials verified
|
|
73
|
+
- `wix-deploy` — deploy target confirmed
|
|
74
|
+
- `wix-stores` — Stores API connected
|
|
75
|
+
|
|
76
|
+
## Two Credential Files
|
|
77
|
+
|
|
78
|
+
The two config files serve different purposes and can point to different Wix sites:
|
|
79
|
+
|
|
80
|
+
| File | Purpose | Used At | Key Fields |
|
|
81
|
+
|------|---------|---------|------------|
|
|
82
|
+
| `config/.wix.yaml` | Backend services — Wix SDK, data collections, Stores API | Build time + BaaS runtime | `apiKey`, `clientId`, `siteId` |
|
|
83
|
+
| `wix.config.json` | Deployment target — BaaS hosting + CDN | Deploy time only | `appId`, `siteId` |
|
|
84
|
+
|
|
85
|
+
**Headless architecture:** Deploy the BaaS worker to one site (the "app" site via `wix.config.json`) while accessing products, orders, and content on a different site (the "business" site via `.wix.yaml`).
|
|
86
|
+
|
|
87
|
+
**Simple setup:** Both files point to the same site. The `clientId` in `.wix.yaml` equals `appId` in `wix.config.json`.
|
|
88
|
+
|
|
89
|
+
## Deploy Command
|
|
90
|
+
|
|
91
|
+
### `wix-deploy/deploy` (recommended)
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
jay-stack-cli run wix-deploy/deploy --exclude-plugins aiditor
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Internally:
|
|
98
|
+
1. **Bundle** `entry.mjs` (~2.5 MB) — plugins, server elements, framework code
|
|
99
|
+
2. **Parallel:**
|
|
100
|
+
- Upload backend data files → Wix data collection
|
|
101
|
+
- Deploy entry.mjs → BaaS + frontend assets → CDN
|
|
102
|
+
|
|
103
|
+
Options:
|
|
104
|
+
- `--exclude-plugins <names>` — comma-separated plugins to exclude from the bundle
|
|
105
|
+
- `--collection-id <name>` — data collection name (default: `jay-backend-files`)
|
|
106
|
+
- `--static-base-url <url>` — CDN URL prefix for static assets
|
|
107
|
+
- `--dry-run` — preview without uploading
|
|
108
|
+
|
|
109
|
+
### Individual commands (for debugging)
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
jay-stack-cli run wix-deploy/build-entry # bundle entry.mjs only
|
|
113
|
+
jay-stack-cli run wix-deploy/upload-backend # upload data files only
|
|
114
|
+
jay-stack-cli run wix-deploy/deploy-baas # deploy to BaaS + CDN only
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Local Testing
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
node serve.mjs
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Starts a local server at `http://localhost:4000`. Uses the local build directory for backend files (no data collection access needed).
|
|
124
|
+
|
|
125
|
+
## What Gets Deployed Where
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
┌─────────────────────────────────────────────────────────┐
|
|
129
|
+
│ entry.mjs (2.5 MB) → Wix BaaS │
|
|
130
|
+
│ │
|
|
131
|
+
│ Bundled by esbuild: │
|
|
132
|
+
│ ├── Framework serve code │
|
|
133
|
+
│ ├── Plugin code (wix-stores, wix-cart, etc.) │
|
|
134
|
+
│ ├── Server element modules (SSR render functions) │
|
|
135
|
+
│ ├── ssr-runtime (inlined) │
|
|
136
|
+
│ ├── Wix SDK (@wix/sdk, @wix/stores, etc.) │
|
|
137
|
+
│ ├── WixDataArtifactStore (data collection client) │
|
|
138
|
+
│ └── MODULE_REGISTRY (pre-imported module lookups) │
|
|
139
|
+
│ │
|
|
140
|
+
│ No node_modules on disk. No dynamic import() at runtime.│
|
|
141
|
+
└─────────────────────────────────────────────────────────┘
|
|
142
|
+
|
|
143
|
+
┌─────────────────────────────────────────────────────────┐
|
|
144
|
+
│ Wix Data Collection (jay-backend-files) │
|
|
145
|
+
│ │
|
|
146
|
+
│ Eager (loaded on cold start): │
|
|
147
|
+
│ ├── route-manifest.json │
|
|
148
|
+
│ └── build-metadata.json │
|
|
149
|
+
│ │
|
|
150
|
+
│ Lazy (fetched per-route, cached in /tmp): │
|
|
151
|
+
│ ├── page-parts.json (per route) │
|
|
152
|
+
│ └── *.cache.json (per page instance) │
|
|
153
|
+
└─────────────────────────────────────────────────────────┘
|
|
154
|
+
|
|
155
|
+
┌─────────────────────────────────────────────────────────┐
|
|
156
|
+
│ Wix CDN │
|
|
157
|
+
│ │
|
|
158
|
+
│ ├── shared/*.js (framework client runtime) │
|
|
159
|
+
│ ├── pages/**/*.js (route client bundles + hydrate) │
|
|
160
|
+
│ └── pages/**/*.css (route stylesheets) │
|
|
161
|
+
└─────────────────────────────────────────────────────────┘
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Updating After Data Changes
|
|
165
|
+
|
|
166
|
+
When products or CMS content changes, the renderer server updates page files in the data collection. The BaaS instance picks up changes on the next request for that page (cache miss triggers a fresh fetch).
|
|
167
|
+
|
|
168
|
+
To redeploy code changes: `npm run build:production && npm run deploy`.
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ArtifactStore, RouteManifest, CacheEntry, ServerElementModule } from '@
|
|
|
3
3
|
import * as _jay_framework_fullstack_component from '@jay-framework/fullstack-component';
|
|
4
4
|
import { ConsoleContext } from '@jay-framework/fullstack-component';
|
|
5
5
|
import { WixClientService } from '@jay-framework/wix-server-client';
|
|
6
|
+
import { JayHtmlValidatorFn } from '@jay-framework/compiler-shared';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* WixDataArtifactStore — implements ArtifactStore for Wix BaaS deployments.
|
|
@@ -110,4 +111,6 @@ interface SetupResult {
|
|
|
110
111
|
}
|
|
111
112
|
declare function setupWixDeploy(ctx: SetupContext): Promise<SetupResult>;
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
declare const validate: JayHtmlValidatorFn;
|
|
115
|
+
|
|
116
|
+
export { WixDataArtifactStore, type WixDataArtifactStoreOptions, buildEntry, deploy, deployBaas, setupWixDeploy, uploadBackend, validate };
|