@revenexx/sdk 0.0.2
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 +21 -0
- package/README.md +148 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/sdk.js +16340 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/sdk.js +16250 -0
- package/dist/esm/sdk.js.map +1 -0
- package/dist/iife/sdk.js +20101 -0
- package/package.json +56 -0
- package/src/channel.ts +158 -0
- package/src/client.ts +950 -0
- package/src/enums/adapter.ts +4 -0
- package/src/enums/attribute-boolean-status.ts +7 -0
- package/src/enums/attribute-datetime-status.ts +7 -0
- package/src/enums/attribute-email-status.ts +7 -0
- package/src/enums/attribute-enum-status.ts +7 -0
- package/src/enums/attribute-float-status.ts +7 -0
- package/src/enums/attribute-integer-status.ts +7 -0
- package/src/enums/attribute-ip-status.ts +7 -0
- package/src/enums/attribute-line-status.ts +7 -0
- package/src/enums/attribute-longtext-status.ts +7 -0
- package/src/enums/attribute-mediumtext-status.ts +7 -0
- package/src/enums/attribute-point-status.ts +7 -0
- package/src/enums/attribute-polygon-status.ts +7 -0
- package/src/enums/attribute-relationship-status.ts +7 -0
- package/src/enums/attribute-string-status.ts +7 -0
- package/src/enums/attribute-text-status.ts +7 -0
- package/src/enums/attribute-url-status.ts +7 -0
- package/src/enums/attribute-varchar-status.ts +7 -0
- package/src/enums/build-runtime.ts +73 -0
- package/src/enums/code.ts +16 -0
- package/src/enums/collection.ts +4 -0
- package/src/enums/column-boolean-status.ts +7 -0
- package/src/enums/column-datetime-status.ts +7 -0
- package/src/enums/column-email-status.ts +7 -0
- package/src/enums/column-enum-status.ts +7 -0
- package/src/enums/column-float-status.ts +7 -0
- package/src/enums/column-integer-status.ts +7 -0
- package/src/enums/column-ip-status.ts +7 -0
- package/src/enums/column-line-status.ts +7 -0
- package/src/enums/column-longtext-status.ts +7 -0
- package/src/enums/column-mediumtext-status.ts +7 -0
- package/src/enums/column-point-status.ts +7 -0
- package/src/enums/column-polygon-status.ts +7 -0
- package/src/enums/column-relationship-status.ts +7 -0
- package/src/enums/column-string-status.ts +7 -0
- package/src/enums/column-text-status.ts +7 -0
- package/src/enums/column-url-status.ts +7 -0
- package/src/enums/column-varchar-status.ts +7 -0
- package/src/enums/compression.ts +5 -0
- package/src/enums/database-type.ts +4 -0
- package/src/enums/deployment-status.ts +8 -0
- package/src/enums/execution-status.ts +7 -0
- package/src/enums/execution-trigger.ts +5 -0
- package/src/enums/framework.ts +17 -0
- package/src/enums/gravity.ts +11 -0
- package/src/enums/health-antivirus-status.ts +5 -0
- package/src/enums/health-status-status.ts +4 -0
- package/src/enums/index-status.ts +7 -0
- package/src/enums/message-status.ts +7 -0
- package/src/enums/method.ts +9 -0
- package/src/enums/output.ts +9 -0
- package/src/enums/permissions.ts +22 -0
- package/src/enums/priority.ts +4 -0
- package/src/enums/range.ts +5 -0
- package/src/enums/runtime.ts +73 -0
- package/src/enums/runtimes.ts +73 -0
- package/src/enums/scopes.ts +57 -0
- package/src/enums/theme.ts +4 -0
- package/src/enums/timezone.ts +421 -0
- package/src/enums/type.ts +5 -0
- package/src/enums/use-cases.ts +9 -0
- package/src/id.ts +47 -0
- package/src/index.ts +92 -0
- package/src/models.ts +6013 -0
- package/src/operator.ts +308 -0
- package/src/permission.ts +57 -0
- package/src/query.ts +576 -0
- package/src/role.ts +100 -0
- package/src/service.ts +30 -0
- package/src/services/apps.ts +2473 -0
- package/src/services/avatars.ts +744 -0
- package/src/services/carts.ts +1057 -0
- package/src/services/channels.ts +227 -0
- package/src/services/customers.ts +729 -0
- package/src/services/greetings.ts +294 -0
- package/src/services/locale.ts +198 -0
- package/src/services/markets.ts +796 -0
- package/src/services/messaging.ts +3463 -0
- package/src/services/products.ts +3100 -0
- package/src/services/realtime.ts +537 -0
- package/src/services/search.ts +346 -0
- package/src/services/sites.ts +1847 -0
- package/src/services/storage.ts +1076 -0
- package/src/services/tokens.ts +314 -0
- package/types/channel.d.ts +74 -0
- package/types/client.d.ts +211 -0
- package/types/enums/adapter.d.ts +4 -0
- package/types/enums/attribute-boolean-status.d.ts +7 -0
- package/types/enums/attribute-datetime-status.d.ts +7 -0
- package/types/enums/attribute-email-status.d.ts +7 -0
- package/types/enums/attribute-enum-status.d.ts +7 -0
- package/types/enums/attribute-float-status.d.ts +7 -0
- package/types/enums/attribute-integer-status.d.ts +7 -0
- package/types/enums/attribute-ip-status.d.ts +7 -0
- package/types/enums/attribute-line-status.d.ts +7 -0
- package/types/enums/attribute-longtext-status.d.ts +7 -0
- package/types/enums/attribute-mediumtext-status.d.ts +7 -0
- package/types/enums/attribute-point-status.d.ts +7 -0
- package/types/enums/attribute-polygon-status.d.ts +7 -0
- package/types/enums/attribute-relationship-status.d.ts +7 -0
- package/types/enums/attribute-string-status.d.ts +7 -0
- package/types/enums/attribute-text-status.d.ts +7 -0
- package/types/enums/attribute-url-status.d.ts +7 -0
- package/types/enums/attribute-varchar-status.d.ts +7 -0
- package/types/enums/build-runtime.d.ts +73 -0
- package/types/enums/code.d.ts +16 -0
- package/types/enums/collection.d.ts +4 -0
- package/types/enums/column-boolean-status.d.ts +7 -0
- package/types/enums/column-datetime-status.d.ts +7 -0
- package/types/enums/column-email-status.d.ts +7 -0
- package/types/enums/column-enum-status.d.ts +7 -0
- package/types/enums/column-float-status.d.ts +7 -0
- package/types/enums/column-integer-status.d.ts +7 -0
- package/types/enums/column-ip-status.d.ts +7 -0
- package/types/enums/column-line-status.d.ts +7 -0
- package/types/enums/column-longtext-status.d.ts +7 -0
- package/types/enums/column-mediumtext-status.d.ts +7 -0
- package/types/enums/column-point-status.d.ts +7 -0
- package/types/enums/column-polygon-status.d.ts +7 -0
- package/types/enums/column-relationship-status.d.ts +7 -0
- package/types/enums/column-string-status.d.ts +7 -0
- package/types/enums/column-text-status.d.ts +7 -0
- package/types/enums/column-url-status.d.ts +7 -0
- package/types/enums/column-varchar-status.d.ts +7 -0
- package/types/enums/compression.d.ts +5 -0
- package/types/enums/database-type.d.ts +4 -0
- package/types/enums/deployment-status.d.ts +8 -0
- package/types/enums/execution-status.d.ts +7 -0
- package/types/enums/execution-trigger.d.ts +5 -0
- package/types/enums/framework.d.ts +17 -0
- package/types/enums/gravity.d.ts +11 -0
- package/types/enums/health-antivirus-status.d.ts +5 -0
- package/types/enums/health-status-status.d.ts +4 -0
- package/types/enums/index-status.d.ts +7 -0
- package/types/enums/message-status.d.ts +7 -0
- package/types/enums/method.d.ts +9 -0
- package/types/enums/output.d.ts +9 -0
- package/types/enums/permissions.d.ts +22 -0
- package/types/enums/priority.d.ts +4 -0
- package/types/enums/range.d.ts +5 -0
- package/types/enums/runtime.d.ts +73 -0
- package/types/enums/runtimes.d.ts +73 -0
- package/types/enums/scopes.d.ts +57 -0
- package/types/enums/theme.d.ts +4 -0
- package/types/enums/timezone.d.ts +421 -0
- package/types/enums/type.d.ts +5 -0
- package/types/enums/use-cases.d.ts +9 -0
- package/types/id.d.ts +20 -0
- package/types/index.d.ts +92 -0
- package/types/models.d.ts +5830 -0
- package/types/operator.d.ts +180 -0
- package/types/permission.d.ts +43 -0
- package/types/query.d.ts +442 -0
- package/types/role.d.ts +70 -0
- package/types/service.d.ts +11 -0
- package/types/services/apps.d.ts +932 -0
- package/types/services/avatars.d.ts +318 -0
- package/types/services/carts.d.ts +352 -0
- package/types/services/channels.d.ts +75 -0
- package/types/services/customers.d.ts +231 -0
- package/types/services/greetings.d.ts +101 -0
- package/types/services/locale.d.ts +64 -0
- package/types/services/markets.d.ts +274 -0
- package/types/services/messaging.d.ts +1324 -0
- package/types/services/products.d.ts +1014 -0
- package/types/services/realtime.d.ts +134 -0
- package/types/services/search.d.ts +131 -0
- package/types/services/sites.d.ts +689 -0
- package/types/services/storage.d.ts +421 -0
- package/types/services/tokens.d.ts +119 -0
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@revenexx/sdk",
|
|
3
|
+
"homepage": "https://revenexx.com",
|
|
4
|
+
"description": "Revenexx Web SDK for browsers and SSR frameworks.",
|
|
5
|
+
"version": "0.0.2",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"types",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"main": "dist/cjs/sdk.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/esm/sdk.js",
|
|
16
|
+
"require": "./dist/cjs/sdk.js",
|
|
17
|
+
"types": "./types/index.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"module": "dist/esm/sdk.js",
|
|
22
|
+
"types": "types/index.d.ts",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/revenexx-sdks/web"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"prepublishOnly": "npm run build",
|
|
29
|
+
"build": "npm run build:types && npm run build:libs",
|
|
30
|
+
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types",
|
|
31
|
+
"build:libs": "rollup -c"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"json-bigint": "1.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@babel/core": "7.19.6",
|
|
38
|
+
"@babel/preset-typescript": "7.18.6",
|
|
39
|
+
"@rollup/plugin-babel": "6.0.3",
|
|
40
|
+
"@rollup/plugin-commonjs": "22.0.0",
|
|
41
|
+
"@rollup/plugin-node-resolve": "13.3.0",
|
|
42
|
+
"@rollup/plugin-typescript": "8.3.2",
|
|
43
|
+
"@types/json-bigint": "1.0.4",
|
|
44
|
+
"playwright": "1.56.1",
|
|
45
|
+
"rollup": "2.79.2",
|
|
46
|
+
"serve-handler": "6.1.0",
|
|
47
|
+
"tslib": "2.4.0",
|
|
48
|
+
"typescript": "4.9.5"
|
|
49
|
+
},
|
|
50
|
+
"jsdelivr": "dist/iife/sdk.js",
|
|
51
|
+
"unpkg": "dist/iife/sdk.js",
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"registry": "https://registry.npmjs.org",
|
|
54
|
+
"access": "public"
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/channel.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
interface Root {}
|
|
2
|
+
interface Database { _db: any }
|
|
3
|
+
interface Collection { _coll: any }
|
|
4
|
+
interface Document { _doc: any }
|
|
5
|
+
interface TablesDB { _tdb: any }
|
|
6
|
+
interface Table { _tbl: any }
|
|
7
|
+
interface Row { _row: any }
|
|
8
|
+
interface Bucket { _bkt: any }
|
|
9
|
+
interface File { _file: any }
|
|
10
|
+
interface Func { _fn: any }
|
|
11
|
+
interface Execution { _exec: any }
|
|
12
|
+
interface Team { _team: any }
|
|
13
|
+
interface Membership { _mem: any }
|
|
14
|
+
interface Resolved { _res: any }
|
|
15
|
+
|
|
16
|
+
type Actionable = Document | Row | File | Team | Membership;
|
|
17
|
+
|
|
18
|
+
function normalize(id: string): string {
|
|
19
|
+
if (id === undefined || id === null) {
|
|
20
|
+
throw new Error("Channel ID is required");
|
|
21
|
+
}
|
|
22
|
+
const trimmed = String(id).trim();
|
|
23
|
+
if (trimmed === "") {
|
|
24
|
+
throw new Error("Channel ID is required");
|
|
25
|
+
}
|
|
26
|
+
return trimmed;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class Channel<T> {
|
|
30
|
+
declare _type: T;
|
|
31
|
+
|
|
32
|
+
private constructor(private readonly segments: string[]) {}
|
|
33
|
+
|
|
34
|
+
private next<N>(segment: string, id?: string): Channel<N> {
|
|
35
|
+
const segments =
|
|
36
|
+
id === undefined
|
|
37
|
+
? [...this.segments, segment]
|
|
38
|
+
: [...this.segments, segment, normalize(id)];
|
|
39
|
+
|
|
40
|
+
return new Channel<N>(segments) as any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private resolve(action: string): Channel<Resolved> {
|
|
44
|
+
return new Channel<Resolved>([...this.segments, action]) as any;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
toString(): string {
|
|
48
|
+
return this.segments.join(".");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// --- DATABASE ROUTE ---
|
|
52
|
+
// Only available on Channel<Database>
|
|
53
|
+
collection(this: Channel<Database>, id: string): Channel<Collection> {
|
|
54
|
+
return this.next<Collection>("collections", id);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Only available on Channel<Collection>
|
|
58
|
+
document(this: Channel<Collection>, id?: string): Channel<Document> {
|
|
59
|
+
// Default: no document ID segment
|
|
60
|
+
return this.next<Document>("documents", id);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// --- TABLESDB ROUTE ---
|
|
64
|
+
table(this: Channel<TablesDB>, id: string): Channel<Table> {
|
|
65
|
+
return this.next<Table>("tables", id);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
row(this: Channel<Table>, id?: string): Channel<Row> {
|
|
69
|
+
// Default: no row ID segment
|
|
70
|
+
return this.next<Row>("rows", id);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// --- BUCKET ROUTE ---
|
|
74
|
+
file(this: Channel<Bucket>, id?: string): Channel<File> {
|
|
75
|
+
// Default: no file ID segment
|
|
76
|
+
return this.next<File>("files", id);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// --- TERMINAL ACTIONS ---
|
|
80
|
+
// Restricted to the Actionable union
|
|
81
|
+
create(this: Channel<Actionable>): Channel<Resolved> {
|
|
82
|
+
return this.resolve("create");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
upsert(this: Channel<Document | Row>): Channel<Resolved> {
|
|
86
|
+
return this.resolve("upsert");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
update(this: Channel<Actionable>): Channel<Resolved> {
|
|
90
|
+
return this.resolve("update");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
delete(this: Channel<Actionable>): Channel<Resolved> {
|
|
94
|
+
return this.resolve("delete");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// --- ROOT FACTORIES ---
|
|
98
|
+
static database(id: string) {
|
|
99
|
+
return new Channel<Database>(["databases", normalize(id)]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static execution(id: string) {
|
|
103
|
+
return new Channel<Execution>(["executions", normalize(id)]);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static tablesdb(id: string) {
|
|
107
|
+
return new Channel<TablesDB>(["tablesdb", normalize(id)]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static bucket(id: string) {
|
|
111
|
+
return new Channel<Bucket>(["buckets", normalize(id)]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static function(id: string) {
|
|
115
|
+
return new Channel<Func>(["functions", normalize(id)]);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static team(id: string) {
|
|
119
|
+
return new Channel<Team>(["teams", normalize(id)]);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static membership(id: string) {
|
|
123
|
+
return new Channel<Membership>(["memberships", normalize(id)]);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static account(): string {
|
|
127
|
+
return "account";
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Global events
|
|
131
|
+
static documents(): string {
|
|
132
|
+
return "documents";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static rows(): string {
|
|
136
|
+
return "rows";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static files(): string {
|
|
140
|
+
return "files";
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static executions(): string {
|
|
144
|
+
return "executions";
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static teams(): string {
|
|
148
|
+
return "teams";
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static memberships(): string {
|
|
152
|
+
return "memberships";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Export types for backward compatibility with realtime
|
|
157
|
+
export type ActionableChannel = Channel<Document> | Channel<Row> | Channel<File> | Channel<Execution> | Channel<Team> | Channel<Membership>;
|
|
158
|
+
export type ResolvedChannel = Channel<Resolved>;
|