@epinova/opticli 0.0.0-stage → 0.28.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/LICENSE +373 -0
- package/README.md +181 -2
- package/lib/index.d.ts +4 -0
- package/lib/index.js +3 -0
- package/lib/opticli.d.ts +100 -0
- package/lib/opticli.js +222 -0
- package/lib/playwright/fixtures.d.ts +71 -0
- package/lib/playwright/fixtures.js +133 -0
- package/lib/playwright/index.d.ts +15 -0
- package/lib/playwright/index.js +8 -0
- package/lib/playwright/setup.d.ts +50 -0
- package/lib/playwright/setup.js +87 -0
- package/lib/types.d.ts +272 -0
- package/lib/types.js +4 -0
- package/lib/version.d.ts +4 -0
- package/lib/version.js +4 -0
- package/package.json +46 -4
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/** A content reference as opticli takes it: an id ("123"), a version ("123_456"), a GUID or a URL ("/en/about/"). */
|
|
2
|
+
export type ContentRef = string;
|
|
3
|
+
export interface Meta {
|
|
4
|
+
/** `db` for reads, `agent` for writes, `cli` for local commands; absent on an error. */
|
|
5
|
+
source?: 'db' | 'agent' | 'cli';
|
|
6
|
+
/** The opticli version that answered. */
|
|
7
|
+
version: string;
|
|
8
|
+
/** Cursor for the next page (`--cursor`). */
|
|
9
|
+
next?: string;
|
|
10
|
+
warnings?: string[];
|
|
11
|
+
/** Present when the database is remote, or has a role other than `local`. */
|
|
12
|
+
database?: {
|
|
13
|
+
server: string;
|
|
14
|
+
name: string;
|
|
15
|
+
local: boolean;
|
|
16
|
+
development?: boolean;
|
|
17
|
+
role?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface OkEnvelope<T> {
|
|
21
|
+
ok: true;
|
|
22
|
+
data: T;
|
|
23
|
+
meta: Meta;
|
|
24
|
+
}
|
|
25
|
+
/** `error.code`, with the exit code in comments. */
|
|
26
|
+
export type ErrorCode = 'usage' | 'internal' | 'not_found' | 'refused' | 'unreachable' | 'login_failed' | 'timeout' | 'conflict' | 'validation' | 'drift' | 'needs_selection' | 'job_failed' | 'cancelled';
|
|
27
|
+
export interface ErrorBody {
|
|
28
|
+
code: ErrorCode;
|
|
29
|
+
message: string;
|
|
30
|
+
/** What to do next. */
|
|
31
|
+
hint?: string;
|
|
32
|
+
details?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface ErrorEnvelope {
|
|
35
|
+
ok: false;
|
|
36
|
+
error: ErrorBody;
|
|
37
|
+
/** opticli 0.27.0 and newer: the version that failed. */
|
|
38
|
+
meta?: Pick<Meta, 'version'>;
|
|
39
|
+
}
|
|
40
|
+
export type Envelope<T> = OkEnvelope<T> | ErrorEnvelope;
|
|
41
|
+
/**
|
|
42
|
+
* A property value as `--values` takes it: a string (also HTML for rich text, an id for a reference), number, boolean
|
|
43
|
+
* or null (clears it), or a structured value (a ContentArea, a link, a local block, a list).
|
|
44
|
+
*/
|
|
45
|
+
export type PropertyValue = string | number | boolean | null | readonly ContentAreaItem[] | LinkValue | readonly PropertyValue[] | {
|
|
46
|
+
readonly [property: string]: PropertyValue;
|
|
47
|
+
};
|
|
48
|
+
/** A ContentArea item: existing content by ref or GUID, or an inline block (CMS 12.20+). */
|
|
49
|
+
export type ContentAreaItem = {
|
|
50
|
+
readonly ref: ContentRef;
|
|
51
|
+
readonly displayOption?: string;
|
|
52
|
+
readonly group?: string;
|
|
53
|
+
readonly visitorGroups?: readonly string[];
|
|
54
|
+
} | {
|
|
55
|
+
readonly guid: string;
|
|
56
|
+
readonly displayOption?: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly type: string;
|
|
59
|
+
readonly name?: string;
|
|
60
|
+
readonly properties: Properties;
|
|
61
|
+
readonly displayOption?: string;
|
|
62
|
+
};
|
|
63
|
+
export interface LinkValue {
|
|
64
|
+
readonly href: ContentRef;
|
|
65
|
+
readonly text?: string;
|
|
66
|
+
readonly title?: string;
|
|
67
|
+
readonly target?: string;
|
|
68
|
+
}
|
|
69
|
+
export type Properties = {
|
|
70
|
+
readonly [property: string]: PropertyValue;
|
|
71
|
+
};
|
|
72
|
+
export interface ServeResult {
|
|
73
|
+
state: 'running' | 'stopped' | 'starting' | (string & {});
|
|
74
|
+
message: string;
|
|
75
|
+
mode?: 'background' | 'foreground' | 'ide';
|
|
76
|
+
pid?: number;
|
|
77
|
+
port?: number;
|
|
78
|
+
/** Where the site agent listens (HTTP on 127.0.0.1). */
|
|
79
|
+
url?: string;
|
|
80
|
+
/** With `--https`: the address to browse. */
|
|
81
|
+
browseUrl?: string;
|
|
82
|
+
scheduler?: 'on' | 'off';
|
|
83
|
+
/** The site agent the running site has: its opticli version, CMS version and runtime. */
|
|
84
|
+
agent?: {
|
|
85
|
+
version: string;
|
|
86
|
+
protocol: number;
|
|
87
|
+
cmsVersion: string;
|
|
88
|
+
runtime: string;
|
|
89
|
+
environment: string;
|
|
90
|
+
};
|
|
91
|
+
/** `serve --stop`: whether a site was stopped. */
|
|
92
|
+
stopped?: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface ChangedProperty {
|
|
95
|
+
property: string;
|
|
96
|
+
before?: unknown;
|
|
97
|
+
after?: unknown;
|
|
98
|
+
}
|
|
99
|
+
/** What `create`, `set`, `publish` and the other single writes return. */
|
|
100
|
+
export interface WriteResult {
|
|
101
|
+
ref: ContentRef;
|
|
102
|
+
/** The version written (`id_version`); for a dry run, the version the change was applied to. */
|
|
103
|
+
version?: string;
|
|
104
|
+
guid?: string;
|
|
105
|
+
type?: string;
|
|
106
|
+
name?: string;
|
|
107
|
+
language?: string;
|
|
108
|
+
status?: 'published' | 'checkedOut' | 'checkedIn' | 'delayedPublish' | 'awaitingApproval' | (string & {});
|
|
109
|
+
parent?: ContentRef;
|
|
110
|
+
saved: boolean;
|
|
111
|
+
published: boolean;
|
|
112
|
+
dryRun: boolean;
|
|
113
|
+
valid: boolean;
|
|
114
|
+
baseVersion?: string;
|
|
115
|
+
changes?: ChangedProperty[];
|
|
116
|
+
validation?: {
|
|
117
|
+
property?: string;
|
|
118
|
+
message: string;
|
|
119
|
+
severity?: string;
|
|
120
|
+
}[];
|
|
121
|
+
/** The version that was live before a publish: publish it again to go back. */
|
|
122
|
+
previouslyPublished?: string;
|
|
123
|
+
/**
|
|
124
|
+
* The public URL, host-relative on the served site as `get` shows it; for a draft of content never published, where
|
|
125
|
+
* it will be. None for blocks, folders and a dry-run create.
|
|
126
|
+
*/
|
|
127
|
+
url?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface DeleteResult {
|
|
130
|
+
ref: ContentRef;
|
|
131
|
+
guid: string;
|
|
132
|
+
name: string;
|
|
133
|
+
parent: ContentRef;
|
|
134
|
+
previousParent: ContentRef;
|
|
135
|
+
moved: boolean;
|
|
136
|
+
dryRun: boolean;
|
|
137
|
+
descendants: number;
|
|
138
|
+
recycleBin: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface UrlResult {
|
|
141
|
+
ref: ContentRef;
|
|
142
|
+
guid: string;
|
|
143
|
+
type: string;
|
|
144
|
+
languages: {
|
|
145
|
+
language: string;
|
|
146
|
+
name: string;
|
|
147
|
+
status: string;
|
|
148
|
+
path: string | null;
|
|
149
|
+
url: string | null;
|
|
150
|
+
site: string;
|
|
151
|
+
}[];
|
|
152
|
+
}
|
|
153
|
+
export interface PropertyOut {
|
|
154
|
+
type: string;
|
|
155
|
+
value: unknown;
|
|
156
|
+
culture?: string;
|
|
157
|
+
truncated?: boolean;
|
|
158
|
+
length?: number;
|
|
159
|
+
}
|
|
160
|
+
/** What `get` returns. */
|
|
161
|
+
export interface ContentItem {
|
|
162
|
+
ref: ContentRef;
|
|
163
|
+
guid: string;
|
|
164
|
+
type: string;
|
|
165
|
+
name: string;
|
|
166
|
+
language: string;
|
|
167
|
+
status: string;
|
|
168
|
+
url?: string;
|
|
169
|
+
kind: 'page' | 'block' | 'media' | 'folder' | (string & {});
|
|
170
|
+
version: string;
|
|
171
|
+
parent: ContentRef;
|
|
172
|
+
saved: string;
|
|
173
|
+
changedBy: string;
|
|
174
|
+
properties: Record<string, PropertyOut>;
|
|
175
|
+
}
|
|
176
|
+
interface StepBase {
|
|
177
|
+
/** Names what this step makes, for "$id" in later steps (needed with a plan's `guidNamespace`). */
|
|
178
|
+
readonly id?: string;
|
|
179
|
+
readonly guid?: string;
|
|
180
|
+
readonly publish?: boolean;
|
|
181
|
+
readonly lang?: string;
|
|
182
|
+
}
|
|
183
|
+
export type PlanStep = (StepBase & {
|
|
184
|
+
readonly op: 'create';
|
|
185
|
+
readonly parent?: ContentRef;
|
|
186
|
+
readonly for?: ContentRef;
|
|
187
|
+
readonly type: string;
|
|
188
|
+
readonly name: string;
|
|
189
|
+
readonly properties?: Properties;
|
|
190
|
+
}) | (StepBase & {
|
|
191
|
+
readonly op: 'block';
|
|
192
|
+
readonly type: string;
|
|
193
|
+
readonly name: string;
|
|
194
|
+
readonly for?: ContentRef;
|
|
195
|
+
readonly parent?: ContentRef;
|
|
196
|
+
readonly properties?: Properties;
|
|
197
|
+
}) | (StepBase & {
|
|
198
|
+
readonly op: 'upload';
|
|
199
|
+
readonly file: string;
|
|
200
|
+
readonly for?: ContentRef;
|
|
201
|
+
readonly parent?: ContentRef;
|
|
202
|
+
readonly name?: string;
|
|
203
|
+
readonly properties?: Properties;
|
|
204
|
+
}) | (StepBase & {
|
|
205
|
+
readonly op: 'set';
|
|
206
|
+
readonly ref: ContentRef;
|
|
207
|
+
readonly properties?: Properties;
|
|
208
|
+
readonly name?: string;
|
|
209
|
+
readonly from?: string;
|
|
210
|
+
}) | (StepBase & {
|
|
211
|
+
readonly op: 'area';
|
|
212
|
+
readonly ref: ContentRef;
|
|
213
|
+
readonly property: string;
|
|
214
|
+
readonly action: 'add' | 'remove' | 'move' | 'set';
|
|
215
|
+
readonly item?: ContentRef;
|
|
216
|
+
readonly type?: string;
|
|
217
|
+
readonly values?: Properties;
|
|
218
|
+
readonly at?: number;
|
|
219
|
+
readonly displayOption?: string;
|
|
220
|
+
}) | (StepBase & {
|
|
221
|
+
readonly op: 'publish' | 'unpublish' | 'discard';
|
|
222
|
+
readonly ref: ContentRef;
|
|
223
|
+
readonly version?: string;
|
|
224
|
+
}) | (StepBase & {
|
|
225
|
+
readonly op: 'move';
|
|
226
|
+
readonly ref: ContentRef;
|
|
227
|
+
readonly to: ContentRef;
|
|
228
|
+
}) | (StepBase & {
|
|
229
|
+
readonly op: 'delete';
|
|
230
|
+
readonly ref: ContentRef;
|
|
231
|
+
readonly ignoreReferences?: boolean;
|
|
232
|
+
}) | (StepBase & {
|
|
233
|
+
readonly op: 'restore';
|
|
234
|
+
readonly ref: ContentRef;
|
|
235
|
+
readonly to?: ContentRef;
|
|
236
|
+
}) | (StepBase & {
|
|
237
|
+
readonly op: 'translate';
|
|
238
|
+
readonly ref: ContentRef;
|
|
239
|
+
readonly lang: string;
|
|
240
|
+
readonly name?: string;
|
|
241
|
+
readonly properties?: Properties;
|
|
242
|
+
});
|
|
243
|
+
export interface Plan {
|
|
244
|
+
/** Gives every create, block and upload a GUID derived from its `id`, so the plan can run again. */
|
|
245
|
+
readonly guidNamespace?: string;
|
|
246
|
+
readonly operations: readonly PlanStep[];
|
|
247
|
+
}
|
|
248
|
+
/** The `id`s a plan's steps declare, as a union of string literals for a plan written `as const`. */
|
|
249
|
+
export type PlanIds<P extends Plan> = P['operations'][number] extends infer S ? (S extends {
|
|
250
|
+
readonly id: infer I extends string;
|
|
251
|
+
} ? I : never) : never;
|
|
252
|
+
export interface PlanStepResult {
|
|
253
|
+
index: number;
|
|
254
|
+
op: PlanStep['op'] | (string & {});
|
|
255
|
+
id?: string;
|
|
256
|
+
guid?: string;
|
|
257
|
+
status: 'saved' | 'unchanged' | 'valid' | 'simulated' | 'deferred' | 'invalid' | 'failed' | (string & {});
|
|
258
|
+
result?: Partial<WriteResult> & {
|
|
259
|
+
existing?: boolean;
|
|
260
|
+
restored?: boolean;
|
|
261
|
+
};
|
|
262
|
+
error?: ErrorBody;
|
|
263
|
+
warnings?: string[];
|
|
264
|
+
undo?: unknown;
|
|
265
|
+
}
|
|
266
|
+
export interface ApplyResult {
|
|
267
|
+
dryRun: boolean;
|
|
268
|
+
operations: PlanStepResult[];
|
|
269
|
+
/** `id` of each create, block and upload → the content it made or updated. */
|
|
270
|
+
created: Record<string, ContentRef>;
|
|
271
|
+
}
|
|
272
|
+
export {};
|
package/lib/types.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Types for opticli's JSON output: the README's "Output and exit codes" and skill/reference.md.
|
|
2
|
+
// Hand-written for the commands a test suite needs; result types list the fields worth reading, and opticli may add
|
|
3
|
+
// more. Input types are readonly, so plans and values written `as const` fit.
|
|
4
|
+
export {};
|
package/lib/version.d.ts
ADDED
package/lib/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epinova/opticli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.28.0",
|
|
4
|
+
"description": "Typed Node API and Playwright fixtures for opticli: start an Optimizely CMS site, seed test content and clean up after the tests",
|
|
5
|
+
"license": "MPL-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"optimizely",
|
|
9
|
+
"episerver",
|
|
10
|
+
"cms",
|
|
11
|
+
"playwright",
|
|
12
|
+
"testing",
|
|
13
|
+
"opticli"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/epinova/opticli/tree/main/npm#readme",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/epinova/opticli.git",
|
|
19
|
+
"directory": "npm"
|
|
20
|
+
},
|
|
21
|
+
"bugs": "https://github.com/epinova/opticli/issues",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18"
|
|
24
|
+
},
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./lib/index.d.ts",
|
|
28
|
+
"default": "./lib/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./playwright": {
|
|
31
|
+
"types": "./lib/playwright/index.d.ts",
|
|
32
|
+
"default": "./lib/playwright/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@playwright/test": ">=1.40"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"@playwright/test": {
|
|
40
|
+
"optional": true
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"lib",
|
|
45
|
+
"README.md",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
]
|
|
48
|
+
}
|