@fluentcms/client 0.0.0-stage → 1.0.0-preview.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/README.md +14 -2
- package/dist/client.d.ts +48 -0
- package/dist/client.js +148 -0
- package/dist/fields.d.ts +123 -0
- package/dist/fields.js +150 -0
- package/dist/filters.d.ts +28 -0
- package/dist/filters.js +9 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +5 -0
- package/dist/problem.d.ts +14 -0
- package/dist/problem.js +41 -0
- package/dist/query.d.ts +14 -0
- package/dist/query.js +99 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.js +1 -0
- package/package.json +31 -4
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @fluentcms/client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A minimal typed client for [FluentCMS](https://github.com/fluentcms/FluentCMS), a headless CMS for .NET: Delivery reads, content management, typed filters, paging and the problems the API answers. It is ES modules over `fetch`, with no runtime dependency.
|
|
4
|
+
|
|
5
|
+
`fluentcms generate typescript --url https://cms.example.com --output src/cms` writes the types and field builders of an instance's schema, and that module imports this package:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { ArticleFields, createClient } from "./cms/fluentcms.js";
|
|
9
|
+
|
|
10
|
+
const cms = createClient({ baseUrl: "https://cms.example.com/" });
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
An answer that is not a success throws `FluentCmsProblem` with the status and, for a problem of the API, its `code`. A success whose body is not JSON, such as a page of a proxy, throws it too, with no code and the detail `The answer is not JSON.`, and an empty success answers `undefined`.
|
|
14
|
+
|
|
15
|
+
`FluentCMS.Client` on nuget.org is the same client for .NET.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Query } from "./query.js";
|
|
2
|
+
import type { Entry, EntryPage, Input, PublishResult } from "./types.js";
|
|
3
|
+
export interface ClientOptions {
|
|
4
|
+
baseUrl: string | URL;
|
|
5
|
+
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
export interface WriteOptions {
|
|
9
|
+
locale?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class FluentCmsClient {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(options: ClientOptions);
|
|
14
|
+
list<T extends Entry>(type: string, query?: Query): Promise<EntryPage<T>>;
|
|
15
|
+
get<T extends Entry>(type: string, id: string, query?: Query): Promise<T>;
|
|
16
|
+
getBy<T extends Entry>(type: string, field: string, value: string, query?: Query): Promise<T>;
|
|
17
|
+
getSingleton<T extends Entry>(type: string, query?: Query): Promise<T>;
|
|
18
|
+
create<T extends Entry>(type: string, entry: Input<T>, options?: WriteOptions): Promise<T>;
|
|
19
|
+
update<T extends Entry>(type: string, id: string, entry: Input<T>, version: number, options?: WriteOptions): Promise<T>;
|
|
20
|
+
delete(type: string, id: string): Promise<void>;
|
|
21
|
+
publish<T extends Entry>(type: string, id: string, options?: WriteOptions): Promise<PublishResult<T>>;
|
|
22
|
+
unpublish<T extends Entry>(type: string, id: string, options?: WriteOptions): Promise<T>;
|
|
23
|
+
collection<T extends Entry>(type: string): CollectionClient<T>;
|
|
24
|
+
singleton<T extends Entry>(type: string): SingletonClient<T>;
|
|
25
|
+
}
|
|
26
|
+
export declare class CollectionClient<T extends Entry> {
|
|
27
|
+
#private;
|
|
28
|
+
readonly type: string;
|
|
29
|
+
constructor(client: FluentCmsClient, type: string);
|
|
30
|
+
list(query?: Query): Promise<EntryPage<T>>;
|
|
31
|
+
get(id: string, query?: Query): Promise<T>;
|
|
32
|
+
getBy(field: string, value: string, query?: Query): Promise<T>;
|
|
33
|
+
create(entry: Input<T>, options?: WriteOptions): Promise<T>;
|
|
34
|
+
update(id: string, entry: Input<T>, version: number, options?: WriteOptions): Promise<T>;
|
|
35
|
+
delete(id: string): Promise<void>;
|
|
36
|
+
publish(id: string, options?: WriteOptions): Promise<PublishResult<T>>;
|
|
37
|
+
unpublish(id: string, options?: WriteOptions): Promise<T>;
|
|
38
|
+
}
|
|
39
|
+
export declare class SingletonClient<T extends Entry> {
|
|
40
|
+
#private;
|
|
41
|
+
readonly type: string;
|
|
42
|
+
constructor(client: FluentCmsClient, type: string);
|
|
43
|
+
get(query?: Query): Promise<T>;
|
|
44
|
+
create(entry: Input<T>, options?: WriteOptions): Promise<T>;
|
|
45
|
+
update(id: string, entry: Input<T>, version: number, options?: WriteOptions): Promise<T>;
|
|
46
|
+
publish(id: string, options?: WriteOptions): Promise<PublishResult<T>>;
|
|
47
|
+
unpublish(id: string, options?: WriteOptions): Promise<T>;
|
|
48
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { FluentCmsProblem } from "./problem.js";
|
|
2
|
+
import { toQueryString } from "./query.js";
|
|
3
|
+
const delivery = "api/delivery/v1/";
|
|
4
|
+
const management = "api/management/v1/content/";
|
|
5
|
+
const systemFields = ["id", "status", "locale", "version", "createdAt", "createdBy", "updatedAt", "updatedBy", "publishedAt", "scheduledPublishAt", "scheduledUnpublishAt", "fallbacks"];
|
|
6
|
+
// The Delivery reads and the content group of the Management API over fetch. An answer that is not a success throws
|
|
7
|
+
// FluentCmsProblem.
|
|
8
|
+
export class FluentCmsClient {
|
|
9
|
+
#baseUrl;
|
|
10
|
+
#headers;
|
|
11
|
+
#fetch;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
const base = new URL(options.baseUrl);
|
|
14
|
+
if (!base.pathname.endsWith("/")) {
|
|
15
|
+
base.pathname += "/";
|
|
16
|
+
}
|
|
17
|
+
this.#baseUrl = base;
|
|
18
|
+
this.#headers = options.headers;
|
|
19
|
+
this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
20
|
+
}
|
|
21
|
+
list(type, query) {
|
|
22
|
+
return this.#send("GET", delivery + segment(type), query);
|
|
23
|
+
}
|
|
24
|
+
get(type, id, query) {
|
|
25
|
+
return this.#send("GET", `${delivery}${segment(type)}/${segment(id)}`, query);
|
|
26
|
+
}
|
|
27
|
+
// By a unique field, such as a slug.
|
|
28
|
+
getBy(type, field, value, query) {
|
|
29
|
+
return this.#send("GET", `${delivery}${segment(type)}/by/${segment(field)}/${segment(value)}`, query);
|
|
30
|
+
}
|
|
31
|
+
// A singleton's list route answers its one entry.
|
|
32
|
+
getSingleton(type, query) {
|
|
33
|
+
return this.#send("GET", delivery + segment(type), query);
|
|
34
|
+
}
|
|
35
|
+
create(type, entry, options) {
|
|
36
|
+
return this.#send("POST", management + segment(type), locale(options), body(entry));
|
|
37
|
+
}
|
|
38
|
+
// Replaces the draft at the version read: a field left out is cleared, and another version is a conflict (412).
|
|
39
|
+
update(type, id, entry, version, options) {
|
|
40
|
+
return this.#send("PUT", `${management}${segment(type)}/${segment(id)}`, locale(options), body(entry), version);
|
|
41
|
+
}
|
|
42
|
+
// Moves the entry to the trash, in every locale.
|
|
43
|
+
async delete(type, id) {
|
|
44
|
+
await this.#send("DELETE", `${management}${segment(type)}/${segment(id)}`);
|
|
45
|
+
}
|
|
46
|
+
publish(type, id, options) {
|
|
47
|
+
return this.#send("POST", `${management}${segment(type)}/${segment(id)}/publish`, locale(options));
|
|
48
|
+
}
|
|
49
|
+
unpublish(type, id, options) {
|
|
50
|
+
return this.#send("POST", `${management}${segment(type)}/${segment(id)}/unpublish`, locale(options));
|
|
51
|
+
}
|
|
52
|
+
collection(type) {
|
|
53
|
+
return new CollectionClient(this, type);
|
|
54
|
+
}
|
|
55
|
+
singleton(type) {
|
|
56
|
+
return new SingletonClient(this, type);
|
|
57
|
+
}
|
|
58
|
+
async #send(method, path, query, content, version) {
|
|
59
|
+
const queryString = query ? toQueryString(query) : "";
|
|
60
|
+
const url = new URL(queryString.length > 0 ? `${path}?${queryString}` : path, this.#baseUrl);
|
|
61
|
+
const headers = { Accept: "application/json", ...(await this.#resolveHeaders()) };
|
|
62
|
+
if (content !== undefined) {
|
|
63
|
+
headers["Content-Type"] = "application/json";
|
|
64
|
+
}
|
|
65
|
+
if (version !== undefined) {
|
|
66
|
+
headers["If-Match"] = `"${version}"`;
|
|
67
|
+
}
|
|
68
|
+
const init = { method, headers };
|
|
69
|
+
if (content !== undefined) {
|
|
70
|
+
init.body = JSON.stringify(content);
|
|
71
|
+
}
|
|
72
|
+
const response = await this.#fetch(url, init);
|
|
73
|
+
const text = await response.text();
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
throw new FluentCmsProblem(response.status, parse(text));
|
|
76
|
+
}
|
|
77
|
+
// An empty body answers nothing, as a delete does. A body this client cannot read, such as a page of a proxy, is a
|
|
78
|
+
// problem with no code, as an answer that is not one is.
|
|
79
|
+
if (text.length === 0) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
return JSON.parse(text);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
throw new FluentCmsProblem(response.status, { detail: "The answer is not JSON." });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async #resolveHeaders() {
|
|
90
|
+
const headers = this.#headers;
|
|
91
|
+
return typeof headers === "function" ? await headers() : headers ?? {};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// The calls of one collection, which createClient of the generated module binds to its type.
|
|
95
|
+
export class CollectionClient {
|
|
96
|
+
#client;
|
|
97
|
+
type;
|
|
98
|
+
constructor(client, type) {
|
|
99
|
+
this.#client = client;
|
|
100
|
+
this.type = type;
|
|
101
|
+
}
|
|
102
|
+
list(query) { return this.#client.list(this.type, query); }
|
|
103
|
+
get(id, query) { return this.#client.get(this.type, id, query); }
|
|
104
|
+
getBy(field, value, query) { return this.#client.getBy(this.type, field, value, query); }
|
|
105
|
+
create(entry, options) { return this.#client.create(this.type, entry, options); }
|
|
106
|
+
update(id, entry, version, options) { return this.#client.update(this.type, id, entry, version, options); }
|
|
107
|
+
delete(id) { return this.#client.delete(this.type, id); }
|
|
108
|
+
publish(id, options) { return this.#client.publish(this.type, id, options); }
|
|
109
|
+
unpublish(id, options) { return this.#client.unpublish(this.type, id, options); }
|
|
110
|
+
}
|
|
111
|
+
export class SingletonClient {
|
|
112
|
+
#client;
|
|
113
|
+
type;
|
|
114
|
+
constructor(client, type) {
|
|
115
|
+
this.#client = client;
|
|
116
|
+
this.type = type;
|
|
117
|
+
}
|
|
118
|
+
get(query) { return this.#client.getSingleton(this.type, query); }
|
|
119
|
+
create(entry, options) { return this.#client.create(this.type, entry, options); }
|
|
120
|
+
update(id, entry, version, options) { return this.#client.update(this.type, id, entry, version, options); }
|
|
121
|
+
publish(id, options) { return this.#client.publish(this.type, id, options); }
|
|
122
|
+
unpublish(id, options) { return this.#client.unpublish(this.type, id, options); }
|
|
123
|
+
}
|
|
124
|
+
function segment(value) {
|
|
125
|
+
if (!value) {
|
|
126
|
+
throw new TypeError("A path segment is empty.");
|
|
127
|
+
}
|
|
128
|
+
return encodeURIComponent(value);
|
|
129
|
+
}
|
|
130
|
+
function locale(options) {
|
|
131
|
+
return options?.locale === undefined ? undefined : { locale: options.locale };
|
|
132
|
+
}
|
|
133
|
+
// The fields of the entry; the system fields are the server's.
|
|
134
|
+
function body(entry) {
|
|
135
|
+
const fields = { ...entry };
|
|
136
|
+
for (const name of systemFields) {
|
|
137
|
+
delete fields[name];
|
|
138
|
+
}
|
|
139
|
+
return fields;
|
|
140
|
+
}
|
|
141
|
+
function parse(text) {
|
|
142
|
+
try {
|
|
143
|
+
return text.length > 0 ? JSON.parse(text) : undefined;
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
}
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { FieldFilter, SortField } from "./filters.js";
|
|
2
|
+
export declare abstract class QueryField {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
constructor(path: string);
|
|
5
|
+
toString(): string;
|
|
6
|
+
}
|
|
7
|
+
export type DateValue = string | Date;
|
|
8
|
+
export type NumberValue = number | bigint;
|
|
9
|
+
export declare class TextField extends QueryField {
|
|
10
|
+
eq(value: string): FieldFilter;
|
|
11
|
+
ne(value: string): FieldFilter;
|
|
12
|
+
in(...values: string[]): FieldFilter;
|
|
13
|
+
notIn(...values: string[]): FieldFilter;
|
|
14
|
+
contains(value: string): FieldFilter;
|
|
15
|
+
startsWith(value: string): FieldFilter;
|
|
16
|
+
isNull(): FieldFilter;
|
|
17
|
+
isNotNull(): FieldFilter;
|
|
18
|
+
ascending(): SortField;
|
|
19
|
+
descending(): SortField;
|
|
20
|
+
}
|
|
21
|
+
export declare class LongTextField extends QueryField {
|
|
22
|
+
contains(value: string): FieldFilter;
|
|
23
|
+
startsWith(value: string): FieldFilter;
|
|
24
|
+
isNull(): FieldFilter;
|
|
25
|
+
isNotNull(): FieldFilter;
|
|
26
|
+
}
|
|
27
|
+
export declare class RichTextField extends QueryField {
|
|
28
|
+
isNull(): FieldFilter;
|
|
29
|
+
isNotNull(): FieldFilter;
|
|
30
|
+
}
|
|
31
|
+
export declare class NumberField extends QueryField {
|
|
32
|
+
eq(value: NumberValue): FieldFilter;
|
|
33
|
+
ne(value: NumberValue): FieldFilter;
|
|
34
|
+
in(...values: NumberValue[]): FieldFilter;
|
|
35
|
+
notIn(...values: NumberValue[]): FieldFilter;
|
|
36
|
+
lt(value: NumberValue): FieldFilter;
|
|
37
|
+
lte(value: NumberValue): FieldFilter;
|
|
38
|
+
gt(value: NumberValue): FieldFilter;
|
|
39
|
+
gte(value: NumberValue): FieldFilter;
|
|
40
|
+
between(from: NumberValue, to: NumberValue): FieldFilter;
|
|
41
|
+
isNull(): FieldFilter;
|
|
42
|
+
isNotNull(): FieldFilter;
|
|
43
|
+
ascending(): SortField;
|
|
44
|
+
descending(): SortField;
|
|
45
|
+
}
|
|
46
|
+
export declare class DateField extends QueryField {
|
|
47
|
+
eq(value: DateValue): FieldFilter;
|
|
48
|
+
ne(value: DateValue): FieldFilter;
|
|
49
|
+
in(...values: DateValue[]): FieldFilter;
|
|
50
|
+
notIn(...values: DateValue[]): FieldFilter;
|
|
51
|
+
lt(value: DateValue): FieldFilter;
|
|
52
|
+
lte(value: DateValue): FieldFilter;
|
|
53
|
+
gt(value: DateValue): FieldFilter;
|
|
54
|
+
gte(value: DateValue): FieldFilter;
|
|
55
|
+
between(from: DateValue, to: DateValue): FieldFilter;
|
|
56
|
+
isNull(): FieldFilter;
|
|
57
|
+
isNotNull(): FieldFilter;
|
|
58
|
+
ascending(): SortField;
|
|
59
|
+
descending(): SortField;
|
|
60
|
+
}
|
|
61
|
+
export declare class BooleanField extends QueryField {
|
|
62
|
+
eq(value: boolean): FieldFilter;
|
|
63
|
+
ne(value: boolean): FieldFilter;
|
|
64
|
+
isNull(): FieldFilter;
|
|
65
|
+
isNotNull(): FieldFilter;
|
|
66
|
+
ascending(): SortField;
|
|
67
|
+
descending(): SortField;
|
|
68
|
+
}
|
|
69
|
+
export declare class SelectField extends QueryField {
|
|
70
|
+
eq(option: string): FieldFilter;
|
|
71
|
+
ne(option: string): FieldFilter;
|
|
72
|
+
in(...options: string[]): FieldFilter;
|
|
73
|
+
notIn(...options: string[]): FieldFilter;
|
|
74
|
+
contains(value: string): FieldFilter;
|
|
75
|
+
isNull(): FieldFilter;
|
|
76
|
+
isNotNull(): FieldFilter;
|
|
77
|
+
ascending(): SortField;
|
|
78
|
+
descending(): SortField;
|
|
79
|
+
}
|
|
80
|
+
export declare class SelectListField extends QueryField {
|
|
81
|
+
contains(option: string): FieldFilter;
|
|
82
|
+
in(...options: string[]): FieldFilter;
|
|
83
|
+
notIn(...options: string[]): FieldFilter;
|
|
84
|
+
isNull(): FieldFilter;
|
|
85
|
+
isNotNull(): FieldFilter;
|
|
86
|
+
}
|
|
87
|
+
export declare class RelationField extends QueryField {
|
|
88
|
+
eq(id: string): FieldFilter;
|
|
89
|
+
in(...ids: string[]): FieldFilter;
|
|
90
|
+
isNull(): FieldFilter;
|
|
91
|
+
isNotNull(): FieldFilter;
|
|
92
|
+
}
|
|
93
|
+
export declare class MediaField extends QueryField {
|
|
94
|
+
eq(assetId: string): FieldFilter;
|
|
95
|
+
in(...assetIds: string[]): FieldFilter;
|
|
96
|
+
}
|
|
97
|
+
export declare class JsonField extends QueryField {
|
|
98
|
+
key(name: string): JsonKeyField;
|
|
99
|
+
isNull(): FieldFilter;
|
|
100
|
+
isNotNull(): FieldFilter;
|
|
101
|
+
}
|
|
102
|
+
export declare class JsonKeyField extends QueryField {
|
|
103
|
+
eq(value: string | NumberValue | boolean): FieldFilter;
|
|
104
|
+
ne(value: string | NumberValue | boolean): FieldFilter;
|
|
105
|
+
contains(value: string): FieldFilter;
|
|
106
|
+
}
|
|
107
|
+
export declare class BlocksField extends QueryField {
|
|
108
|
+
hasBlock(blockType: string): FieldFilter;
|
|
109
|
+
isNull(): FieldFilter;
|
|
110
|
+
isNotNull(): FieldFilter;
|
|
111
|
+
}
|
|
112
|
+
export declare class BlockTextField extends QueryField {
|
|
113
|
+
eq(value: string): FieldFilter;
|
|
114
|
+
ne(value: string): FieldFilter;
|
|
115
|
+
contains(value: string): FieldFilter;
|
|
116
|
+
}
|
|
117
|
+
export declare class BlockValueField extends QueryField {
|
|
118
|
+
eq(value: NumberValue | boolean | DateValue): FieldFilter;
|
|
119
|
+
ne(value: NumberValue | boolean | DateValue): FieldFilter;
|
|
120
|
+
}
|
|
121
|
+
export declare class BlockContainsField extends QueryField {
|
|
122
|
+
contains(value: string): FieldFilter;
|
|
123
|
+
}
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// The field types the generated builders return, with the members of FluentCMS.Client's types in camel case, so that
|
|
2
|
+
// ArticleFields.title.contains("x") gives the filter ArticleFields.Title.Contains("x") gives in C#.
|
|
3
|
+
export class QueryField {
|
|
4
|
+
path;
|
|
5
|
+
constructor(path) {
|
|
6
|
+
if (!path) {
|
|
7
|
+
throw new TypeError("A field has a path.");
|
|
8
|
+
}
|
|
9
|
+
this.path = path;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return this.path;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// Functions of the module rather than members, so that a generated builder may name a block type filter or sort.
|
|
16
|
+
function condition(path, operator, value) {
|
|
17
|
+
return value === undefined ? { kind: "field", path, operator } : { kind: "field", path, operator, value };
|
|
18
|
+
}
|
|
19
|
+
function order(path, descending) {
|
|
20
|
+
return { path, descending };
|
|
21
|
+
}
|
|
22
|
+
export class TextField extends QueryField {
|
|
23
|
+
eq(value) { return condition(this.path, "eq", value); }
|
|
24
|
+
ne(value) { return condition(this.path, "ne", value); }
|
|
25
|
+
in(...values) { return condition(this.path, "in", values); }
|
|
26
|
+
notIn(...values) { return condition(this.path, "nin", values); }
|
|
27
|
+
contains(value) { return condition(this.path, "contains", value); }
|
|
28
|
+
startsWith(value) { return condition(this.path, "startsWith", value); }
|
|
29
|
+
isNull() { return condition(this.path, "null"); }
|
|
30
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
31
|
+
ascending() { return order(this.path, false); }
|
|
32
|
+
descending() { return order(this.path, true); }
|
|
33
|
+
}
|
|
34
|
+
export class LongTextField extends QueryField {
|
|
35
|
+
contains(value) { return condition(this.path, "contains", value); }
|
|
36
|
+
startsWith(value) { return condition(this.path, "startsWith", value); }
|
|
37
|
+
isNull() { return condition(this.path, "null"); }
|
|
38
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
39
|
+
}
|
|
40
|
+
export class RichTextField extends QueryField {
|
|
41
|
+
isNull() { return condition(this.path, "null"); }
|
|
42
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
43
|
+
}
|
|
44
|
+
// integer and decimal.
|
|
45
|
+
export class NumberField extends QueryField {
|
|
46
|
+
eq(value) { return condition(this.path, "eq", value); }
|
|
47
|
+
ne(value) { return condition(this.path, "ne", value); }
|
|
48
|
+
in(...values) { return condition(this.path, "in", values); }
|
|
49
|
+
notIn(...values) { return condition(this.path, "nin", values); }
|
|
50
|
+
lt(value) { return condition(this.path, "lt", value); }
|
|
51
|
+
lte(value) { return condition(this.path, "lte", value); }
|
|
52
|
+
gt(value) { return condition(this.path, "gt", value); }
|
|
53
|
+
gte(value) { return condition(this.path, "gte", value); }
|
|
54
|
+
between(from, to) { return condition(this.path, "between", [from, to]); }
|
|
55
|
+
isNull() { return condition(this.path, "null"); }
|
|
56
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
57
|
+
ascending() { return order(this.path, false); }
|
|
58
|
+
descending() { return order(this.path, true); }
|
|
59
|
+
}
|
|
60
|
+
// date (yyyy-MM-dd) and dateTime (a Date, or an ISO 8601 text with an offset).
|
|
61
|
+
export class DateField extends QueryField {
|
|
62
|
+
eq(value) { return condition(this.path, "eq", value); }
|
|
63
|
+
ne(value) { return condition(this.path, "ne", value); }
|
|
64
|
+
in(...values) { return condition(this.path, "in", values); }
|
|
65
|
+
notIn(...values) { return condition(this.path, "nin", values); }
|
|
66
|
+
lt(value) { return condition(this.path, "lt", value); }
|
|
67
|
+
lte(value) { return condition(this.path, "lte", value); }
|
|
68
|
+
gt(value) { return condition(this.path, "gt", value); }
|
|
69
|
+
gte(value) { return condition(this.path, "gte", value); }
|
|
70
|
+
between(from, to) { return condition(this.path, "between", [from, to]); }
|
|
71
|
+
isNull() { return condition(this.path, "null"); }
|
|
72
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
73
|
+
ascending() { return order(this.path, false); }
|
|
74
|
+
descending() { return order(this.path, true); }
|
|
75
|
+
}
|
|
76
|
+
export class BooleanField extends QueryField {
|
|
77
|
+
eq(value) { return condition(this.path, "eq", value); }
|
|
78
|
+
ne(value) { return condition(this.path, "ne", value); }
|
|
79
|
+
isNull() { return condition(this.path, "null"); }
|
|
80
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
81
|
+
ascending() { return order(this.path, false); }
|
|
82
|
+
descending() { return order(this.path, true); }
|
|
83
|
+
}
|
|
84
|
+
export class SelectField extends QueryField {
|
|
85
|
+
eq(option) { return condition(this.path, "eq", option); }
|
|
86
|
+
ne(option) { return condition(this.path, "ne", option); }
|
|
87
|
+
in(...options) { return condition(this.path, "in", options); }
|
|
88
|
+
notIn(...options) { return condition(this.path, "nin", options); }
|
|
89
|
+
contains(value) { return condition(this.path, "contains", value); }
|
|
90
|
+
isNull() { return condition(this.path, "null"); }
|
|
91
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
92
|
+
ascending() { return order(this.path, false); }
|
|
93
|
+
descending() { return order(this.path, true); }
|
|
94
|
+
}
|
|
95
|
+
export class SelectListField extends QueryField {
|
|
96
|
+
contains(option) { return condition(this.path, "contains", option); }
|
|
97
|
+
in(...options) { return condition(this.path, "in", options); }
|
|
98
|
+
notIn(...options) { return condition(this.path, "nin", options); }
|
|
99
|
+
isNull() { return condition(this.path, "null"); }
|
|
100
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
101
|
+
}
|
|
102
|
+
export class RelationField extends QueryField {
|
|
103
|
+
eq(id) { return condition(this.path, "eq", id); }
|
|
104
|
+
in(...ids) { return condition(this.path, "in", ids); }
|
|
105
|
+
isNull() { return condition(this.path, "null"); }
|
|
106
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
107
|
+
}
|
|
108
|
+
export class MediaField extends QueryField {
|
|
109
|
+
eq(assetId) { return condition(this.path, "eq", assetId); }
|
|
110
|
+
in(...assetIds) { return condition(this.path, "in", assetIds); }
|
|
111
|
+
}
|
|
112
|
+
export class JsonField extends QueryField {
|
|
113
|
+
key(name) {
|
|
114
|
+
if (!/^[A-Za-z0-9_]+$/.test(name)) {
|
|
115
|
+
throw new TypeError("A filter reaches one key inside JSON, named with ASCII letters, digits and underscores.");
|
|
116
|
+
}
|
|
117
|
+
return new JsonKeyField(`${this.path}.${name}`);
|
|
118
|
+
}
|
|
119
|
+
isNull() { return condition(this.path, "null"); }
|
|
120
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
121
|
+
}
|
|
122
|
+
export class JsonKeyField extends QueryField {
|
|
123
|
+
eq(value) { return condition(this.path, "eq", value); }
|
|
124
|
+
ne(value) { return condition(this.path, "ne", value); }
|
|
125
|
+
contains(value) { return condition(this.path, "contains", value); }
|
|
126
|
+
}
|
|
127
|
+
// The generated builder of a blocks field derives from it, with a member per block type of the field.
|
|
128
|
+
export class BlocksField extends QueryField {
|
|
129
|
+
hasBlock(blockType) {
|
|
130
|
+
if (!blockType) {
|
|
131
|
+
throw new TypeError("hasBlock takes a block type.");
|
|
132
|
+
}
|
|
133
|
+
return condition(this.path, "hasBlock", blockType);
|
|
134
|
+
}
|
|
135
|
+
isNull() { return condition(this.path, "null"); }
|
|
136
|
+
isNotNull() { return condition(this.path, "notNull"); }
|
|
137
|
+
}
|
|
138
|
+
export class BlockTextField extends QueryField {
|
|
139
|
+
eq(value) { return condition(this.path, "eq", value); }
|
|
140
|
+
ne(value) { return condition(this.path, "ne", value); }
|
|
141
|
+
contains(value) { return condition(this.path, "contains", value); }
|
|
142
|
+
}
|
|
143
|
+
// A number, a boolean or a date one level inside a block.
|
|
144
|
+
export class BlockValueField extends QueryField {
|
|
145
|
+
eq(value) { return condition(this.path, "eq", value); }
|
|
146
|
+
ne(value) { return condition(this.path, "ne", value); }
|
|
147
|
+
}
|
|
148
|
+
export class BlockContainsField extends QueryField {
|
|
149
|
+
contains(value) { return condition(this.path, "contains", value); }
|
|
150
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type FilterOperator = "eq" | "ne" | "in" | "nin" | "lt" | "lte" | "gt" | "gte" | "between" | "contains" | "startsWith" | "null" | "notNull" | "hasBlock";
|
|
2
|
+
export type FilterValue = string | number | bigint | boolean | Date;
|
|
3
|
+
export interface FieldFilter {
|
|
4
|
+
readonly kind: "field";
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly operator: FilterOperator;
|
|
7
|
+
readonly value?: FilterValue | readonly FilterValue[];
|
|
8
|
+
}
|
|
9
|
+
export interface AndFilter {
|
|
10
|
+
readonly kind: "and";
|
|
11
|
+
readonly filters: readonly Filter[];
|
|
12
|
+
}
|
|
13
|
+
export interface OrFilter {
|
|
14
|
+
readonly kind: "or";
|
|
15
|
+
readonly filters: readonly Filter[];
|
|
16
|
+
}
|
|
17
|
+
export interface NotFilter {
|
|
18
|
+
readonly kind: "not";
|
|
19
|
+
readonly filter: Filter;
|
|
20
|
+
}
|
|
21
|
+
export type Filter = FieldFilter | AndFilter | OrFilter | NotFilter;
|
|
22
|
+
export interface SortField {
|
|
23
|
+
readonly path: string;
|
|
24
|
+
readonly descending: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function and(...filters: Filter[]): AndFilter;
|
|
27
|
+
export declare function or(...filters: Filter[]): OrFilter;
|
|
28
|
+
export declare function not(filter: Filter): NotFilter;
|
package/dist/filters.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { FluentCmsClient, CollectionClient, SingletonClient } from "./client.js";
|
|
2
|
+
export type { ClientOptions, WriteOptions } from "./client.js";
|
|
3
|
+
export { QueryField, TextField, LongTextField, RichTextField, NumberField, DateField, BooleanField, SelectField, SelectListField, RelationField, MediaField, JsonField, JsonKeyField, BlocksField, BlockTextField, BlockValueField, BlockContainsField, } from "./fields.js";
|
|
4
|
+
export type { DateValue, NumberValue } from "./fields.js";
|
|
5
|
+
export { and, or, not } from "./filters.js";
|
|
6
|
+
export type { AndFilter, FieldFilter, Filter, FilterOperator, FilterValue, NotFilter, OrFilter, SortField } from "./filters.js";
|
|
7
|
+
export { FluentCmsProblem } from "./problem.js";
|
|
8
|
+
export type { ProblemError } from "./problem.js";
|
|
9
|
+
export { toQueryString } from "./query.js";
|
|
10
|
+
export type { Query } from "./query.js";
|
|
11
|
+
export type { Entry, EntryPage, Input, InputValue, MediaReference, PublishResult, PublishWarning, Reference, Relation, RichText, RichTextMark, RichTextNode, } from "./types.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FluentCmsClient, CollectionClient, SingletonClient } from "./client.js";
|
|
2
|
+
export { QueryField, TextField, LongTextField, RichTextField, NumberField, DateField, BooleanField, SelectField, SelectListField, RelationField, MediaField, JsonField, JsonKeyField, BlocksField, BlockTextField, BlockValueField, BlockContainsField, } from "./fields.js";
|
|
3
|
+
export { and, or, not } from "./filters.js";
|
|
4
|
+
export { FluentCmsProblem } from "./problem.js";
|
|
5
|
+
export { toQueryString } from "./query.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ProblemError {
|
|
2
|
+
path?: string;
|
|
3
|
+
code?: string;
|
|
4
|
+
message?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class FluentCmsProblem extends Error {
|
|
7
|
+
readonly status: number;
|
|
8
|
+
readonly code: string | undefined;
|
|
9
|
+
readonly title: string | undefined;
|
|
10
|
+
readonly detail: string | undefined;
|
|
11
|
+
readonly errors: readonly ProblemError[];
|
|
12
|
+
readonly traceId: string | undefined;
|
|
13
|
+
constructor(status: number, body: unknown);
|
|
14
|
+
}
|
package/dist/problem.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// A problem (RFC 9457) the API answered, with its FCMS code. A response that is not a problem has no code.
|
|
2
|
+
export class FluentCmsProblem extends Error {
|
|
3
|
+
status;
|
|
4
|
+
code;
|
|
5
|
+
title;
|
|
6
|
+
detail;
|
|
7
|
+
errors;
|
|
8
|
+
traceId;
|
|
9
|
+
constructor(status, body) {
|
|
10
|
+
const problem = typeof body === "object" && body !== null ? body : {};
|
|
11
|
+
const code = text(problem["code"]);
|
|
12
|
+
const title = text(problem["title"]);
|
|
13
|
+
const detail = text(problem["detail"]);
|
|
14
|
+
super(`${code ?? status}: ${detail ?? title ?? "the request failed"}`);
|
|
15
|
+
this.name = "FluentCmsProblem";
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.title = title;
|
|
19
|
+
this.detail = detail;
|
|
20
|
+
this.traceId = text(problem["traceId"]);
|
|
21
|
+
this.errors = Array.isArray(problem["errors"])
|
|
22
|
+
? problem["errors"].filter((item) => typeof item === "object" && item !== null).map((item) => error(item))
|
|
23
|
+
: [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function error(item) {
|
|
27
|
+
const result = {};
|
|
28
|
+
const path = text(item["path"]);
|
|
29
|
+
const code = text(item["code"]);
|
|
30
|
+
const message = text(item["message"]);
|
|
31
|
+
if (path !== undefined)
|
|
32
|
+
result.path = path;
|
|
33
|
+
if (code !== undefined)
|
|
34
|
+
result.code = code;
|
|
35
|
+
if (message !== undefined)
|
|
36
|
+
result.message = message;
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
function text(value) {
|
|
40
|
+
return typeof value === "string" ? value : undefined;
|
|
41
|
+
}
|
package/dist/query.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Filter, SortField } from "./filters.js";
|
|
2
|
+
export interface Query {
|
|
3
|
+
filter?: Filter;
|
|
4
|
+
sort?: SortField | readonly SortField[];
|
|
5
|
+
page?: number;
|
|
6
|
+
pageSize?: number;
|
|
7
|
+
cursor?: string;
|
|
8
|
+
fields?: readonly string[];
|
|
9
|
+
populate?: readonly string[];
|
|
10
|
+
depth?: number;
|
|
11
|
+
status?: "published" | "draft";
|
|
12
|
+
locale?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function toQueryString(query: Query): string;
|
package/dist/query.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// The query string of spec 4.4, in its order and with its escaping, without the leading "?". FluentCMS.Client writes the
|
|
2
|
+
// same: a list operand is comma separated, with \, and \\ for a comma and a backslash in a value.
|
|
3
|
+
export function toQueryString(query) {
|
|
4
|
+
const pairs = [];
|
|
5
|
+
if (query.filter) {
|
|
6
|
+
writeFilter(query.filter, "filter", pairs);
|
|
7
|
+
}
|
|
8
|
+
const sort = query.sort === undefined ? [] : Array.isArray(query.sort) ? query.sort : [query.sort];
|
|
9
|
+
if (sort.length > 0) {
|
|
10
|
+
pairs.push(["sort", sort.map((field) => (field.descending ? "-" : "") + field.path).join(",")]);
|
|
11
|
+
}
|
|
12
|
+
add("page", query.page);
|
|
13
|
+
add("pageSize", query.pageSize);
|
|
14
|
+
add("cursor", query.cursor);
|
|
15
|
+
add("fields", query.fields && query.fields.length > 0 ? query.fields.join(",") : undefined);
|
|
16
|
+
add("populate", query.populate && query.populate.length > 0 ? query.populate.join(",") : undefined);
|
|
17
|
+
add("depth", query.depth);
|
|
18
|
+
add("status", query.status);
|
|
19
|
+
add("locale", query.locale);
|
|
20
|
+
return pairs.map(([key, value]) => `${escapeKey(key)}=${escapeValue(value)}`).join("&");
|
|
21
|
+
function add(key, value) {
|
|
22
|
+
if (value !== undefined) {
|
|
23
|
+
pairs.push([key, String(value)]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function writeFilter(filter, prefix, pairs) {
|
|
28
|
+
switch (filter.kind) {
|
|
29
|
+
case "field":
|
|
30
|
+
if ((filter.operator === "in" || filter.operator === "nin" || filter.operator === "between")
|
|
31
|
+
&& (filter.value === undefined || (Array.isArray(filter.value) && filter.value.length === 0))) {
|
|
32
|
+
throw new TypeError(`The filter on '${filter.path}' needs at least one value.`);
|
|
33
|
+
}
|
|
34
|
+
pairs.push([`${prefix}[${filter.path}][${filter.operator}]`, operand(filter)]);
|
|
35
|
+
break;
|
|
36
|
+
case "not":
|
|
37
|
+
writeFilter(filter.filter, `${prefix}[not]`, pairs);
|
|
38
|
+
break;
|
|
39
|
+
case "or":
|
|
40
|
+
if (filter.filters.length === 0) {
|
|
41
|
+
throw new TypeError("An and or an or needs at least one condition.");
|
|
42
|
+
}
|
|
43
|
+
filter.filters.forEach((item, index) => writeFilter(item, `${prefix}[or][${index}]`, pairs));
|
|
44
|
+
break;
|
|
45
|
+
case "and":
|
|
46
|
+
if (filter.filters.length === 0) {
|
|
47
|
+
throw new TypeError("An and or an or needs at least one condition.");
|
|
48
|
+
}
|
|
49
|
+
if (needsIndexes(filter.filters)) {
|
|
50
|
+
filter.filters.forEach((item, index) => writeFilter(item, `${prefix}[and][${index}]`, pairs));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
filter.filters.forEach((item) => writeFilter(item, prefix, pairs));
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Conditions side by side are an implicit and, unless their keys would merge when read back.
|
|
59
|
+
function needsIndexes(filters) {
|
|
60
|
+
const count = (kind) => filters.filter((item) => item.kind === kind).length;
|
|
61
|
+
const keys = filters.filter((item) => item.kind === "field").map((item) => `${item.path}\u0000${item.operator}`);
|
|
62
|
+
return count("and") > 0 || count("or") > 1 || count("not") > 1 || new Set(keys).size !== keys.length;
|
|
63
|
+
}
|
|
64
|
+
function operand(filter) {
|
|
65
|
+
if (filter.operator === "null" || filter.operator === "notNull") {
|
|
66
|
+
return "true";
|
|
67
|
+
}
|
|
68
|
+
const value = filter.value;
|
|
69
|
+
if (Array.isArray(value)) {
|
|
70
|
+
return value.map((item) => escapeItem(text(item))).join(",");
|
|
71
|
+
}
|
|
72
|
+
const single = value;
|
|
73
|
+
return filter.operator === "in" || filter.operator === "nin" || filter.operator === "between" ? escapeItem(text(single)) : text(single);
|
|
74
|
+
}
|
|
75
|
+
// A Date in UTC with Z and no trailing zeros in its fraction, which a DateTimeOffset also gives in C#.
|
|
76
|
+
function text(value) {
|
|
77
|
+
if (value === undefined) {
|
|
78
|
+
return "";
|
|
79
|
+
}
|
|
80
|
+
if (value instanceof Date) {
|
|
81
|
+
const iso = value.toISOString();
|
|
82
|
+
const fraction = iso.slice(20, 23).replace(/0+$/, "");
|
|
83
|
+
return iso.slice(0, 19) + (fraction.length > 0 ? `.${fraction}` : "") + "Z";
|
|
84
|
+
}
|
|
85
|
+
return typeof value === "boolean" ? (value ? "true" : "false") : String(value);
|
|
86
|
+
}
|
|
87
|
+
function escapeItem(value) {
|
|
88
|
+
return value.replaceAll("\\", "\\\\").replaceAll(",", "\\,");
|
|
89
|
+
}
|
|
90
|
+
// encodeURIComponent leaves !'()* alone, which Uri.EscapeDataString in C# escapes; the grammar keeps , [ ] and *.
|
|
91
|
+
function escape(value) {
|
|
92
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (character) => "%" + character.charCodeAt(0).toString(16).toUpperCase());
|
|
93
|
+
}
|
|
94
|
+
function escapeKey(key) {
|
|
95
|
+
return escape(key).replaceAll("%5B", "[").replaceAll("%5D", "]");
|
|
96
|
+
}
|
|
97
|
+
function escapeValue(value) {
|
|
98
|
+
return escape(value).replaceAll("%2C", ",").replaceAll("%2A", "*");
|
|
99
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export interface Entry {
|
|
2
|
+
id: string;
|
|
3
|
+
status?: string;
|
|
4
|
+
locale?: string;
|
|
5
|
+
version?: number;
|
|
6
|
+
createdAt?: string;
|
|
7
|
+
createdBy?: string;
|
|
8
|
+
updatedAt?: string;
|
|
9
|
+
updatedBy?: string;
|
|
10
|
+
publishedAt?: string | null;
|
|
11
|
+
scheduledPublishAt?: string | null;
|
|
12
|
+
scheduledUnpublishAt?: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface Reference<TType extends string = string> {
|
|
15
|
+
id: string;
|
|
16
|
+
type: TType;
|
|
17
|
+
}
|
|
18
|
+
export type Relation<TEntry, TType extends string = string> = Reference<TType> | (TEntry & Reference<TType>);
|
|
19
|
+
export interface MediaReference extends Reference<"media"> {
|
|
20
|
+
fileName?: string;
|
|
21
|
+
mimeType?: string;
|
|
22
|
+
size?: number;
|
|
23
|
+
width?: number | null;
|
|
24
|
+
height?: number | null;
|
|
25
|
+
title?: string | null;
|
|
26
|
+
alt?: string | null;
|
|
27
|
+
caption?: string | null;
|
|
28
|
+
credit?: string | null;
|
|
29
|
+
focalPoint?: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
} | null;
|
|
33
|
+
urls?: {
|
|
34
|
+
original?: string;
|
|
35
|
+
presets?: Record<string, string>;
|
|
36
|
+
template?: string;
|
|
37
|
+
} | null;
|
|
38
|
+
}
|
|
39
|
+
export interface RichTextMark {
|
|
40
|
+
type: string;
|
|
41
|
+
attrs?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export interface RichTextNode {
|
|
44
|
+
type: string;
|
|
45
|
+
attrs?: Record<string, unknown>;
|
|
46
|
+
content?: RichTextNode[];
|
|
47
|
+
marks?: RichTextMark[];
|
|
48
|
+
text?: string;
|
|
49
|
+
}
|
|
50
|
+
export type RichText = (RichTextNode & {
|
|
51
|
+
type: "doc";
|
|
52
|
+
}) | string;
|
|
53
|
+
export interface EntryPage<T> {
|
|
54
|
+
items: T[];
|
|
55
|
+
total?: number | null;
|
|
56
|
+
page?: number | null;
|
|
57
|
+
pageSize?: number | null;
|
|
58
|
+
nextCursor?: string | null;
|
|
59
|
+
}
|
|
60
|
+
export interface PublishWarning {
|
|
61
|
+
path: string;
|
|
62
|
+
code: string;
|
|
63
|
+
message: string;
|
|
64
|
+
targetType?: string | null;
|
|
65
|
+
targetId?: string | null;
|
|
66
|
+
}
|
|
67
|
+
export interface PublishResult<T> {
|
|
68
|
+
entry: T;
|
|
69
|
+
warnings: PublishWarning[];
|
|
70
|
+
}
|
|
71
|
+
export type Input<T> = {
|
|
72
|
+
[K in Exclude<keyof T, keyof Entry | "fallbacks">]?: InputValue<T[K]>;
|
|
73
|
+
};
|
|
74
|
+
export type InputValue<V> = V extends Reference<string> ? string : V extends readonly (infer Item)[] ? InputValue<Item>[] : V extends object ? {
|
|
75
|
+
[K in keyof V]: InputValue<V[K]>;
|
|
76
|
+
} : V;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentcms/client",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0-preview.1",
|
|
4
|
+
"description": "A minimal typed client for FluentCMS: Delivery reads, content management, typed filters, paging and problems.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/fluentcms/FluentCMS.git",
|
|
9
|
+
"directory": "clients/typescript"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.json",
|
|
24
|
+
"pretest": "tsc -p tsconfig.json",
|
|
25
|
+
"test": "tsc -p tsconfig.test.json && node --test \"dist-test/test/*.test.js\""
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "6.0.3"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20"
|
|
32
|
+
}
|
|
33
|
+
}
|