@arrirpc/codegen-utils 0.45.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,168 @@
1
+ import * as _arrirpc_schema from '@arrirpc/schema';
2
+ import { AppDefinition } from './index.js';
3
+ import 'jtd-utils';
4
+ import 'scule';
5
+
6
+ declare const TestUserSettingsSchema: _arrirpc_schema.AObjectSchema<{
7
+ notificationsEnabled: boolean;
8
+ preferredTheme: "dark-mode" | "light-mode" | "system";
9
+ }, false>;
10
+ declare const TestUserPhotoSchema: _arrirpc_schema.AObjectSchema<{
11
+ url: string;
12
+ width: number;
13
+ height: number;
14
+ bytes: bigint;
15
+ nanoseconds: bigint;
16
+ }, false>;
17
+ declare const TestUserNotificationSchema: _arrirpc_schema.ADiscriminatorSchema<{
18
+ postId: string;
19
+ userId: string;
20
+ notificationType: "POST_LIKE";
21
+ } | {
22
+ postId: string;
23
+ userId: string;
24
+ commentText: string;
25
+ notificationType: "POST_COMMENT";
26
+ }>;
27
+ interface BinaryTree {
28
+ left: BinaryTree | null;
29
+ right: BinaryTree | null;
30
+ }
31
+ declare const TestUserSchema: _arrirpc_schema.AObjectSchema<{
32
+ id: string;
33
+ role: "standard" | "admin";
34
+ photo: {
35
+ url: string;
36
+ width: number;
37
+ height: number;
38
+ bytes: bigint;
39
+ nanoseconds: bigint;
40
+ } | null;
41
+ createdAt: Date;
42
+ numFollowers: number;
43
+ settings: {
44
+ notificationsEnabled: boolean;
45
+ preferredTheme: "dark-mode" | "light-mode" | "system";
46
+ };
47
+ lastNotification: {
48
+ postId: string;
49
+ userId: string;
50
+ notificationType: "POST_LIKE";
51
+ } | {
52
+ postId: string;
53
+ userId: string;
54
+ commentText: string;
55
+ notificationType: "POST_COMMENT";
56
+ } | null;
57
+ recentNotifications: ({
58
+ postId: string;
59
+ userId: string;
60
+ notificationType: "POST_LIKE";
61
+ } | {
62
+ postId: string;
63
+ userId: string;
64
+ commentText: string;
65
+ notificationType: "POST_COMMENT";
66
+ })[];
67
+ bookmarks: Record<string, {
68
+ postId: string;
69
+ userId: string;
70
+ }>;
71
+ bio: string | undefined;
72
+ metadata: Record<string, any>;
73
+ randomList: any[];
74
+ binaryTree: BinaryTree;
75
+ }, false>;
76
+ declare const TestUserParams: _arrirpc_schema.AObjectSchema<{
77
+ userId: string;
78
+ }, false>;
79
+ declare const TestUpdateUserParams: _arrirpc_schema.AObjectSchema<Pick<{
80
+ id: string;
81
+ role: "standard" | "admin";
82
+ photo: {
83
+ url: string;
84
+ width: number;
85
+ height: number;
86
+ bytes: bigint;
87
+ nanoseconds: bigint;
88
+ } | null;
89
+ createdAt: Date;
90
+ numFollowers: number;
91
+ settings: {
92
+ notificationsEnabled: boolean;
93
+ preferredTheme: "dark-mode" | "light-mode" | "system";
94
+ };
95
+ lastNotification: {
96
+ postId: string;
97
+ userId: string;
98
+ notificationType: "POST_LIKE";
99
+ } | {
100
+ postId: string;
101
+ userId: string;
102
+ commentText: string;
103
+ notificationType: "POST_COMMENT";
104
+ } | null;
105
+ recentNotifications: ({
106
+ postId: string;
107
+ userId: string;
108
+ notificationType: "POST_LIKE";
109
+ } | {
110
+ postId: string;
111
+ userId: string;
112
+ commentText: string;
113
+ notificationType: "POST_COMMENT";
114
+ })[];
115
+ bookmarks: Record<string, {
116
+ postId: string;
117
+ userId: string;
118
+ }>;
119
+ bio: string | undefined;
120
+ metadata: Record<string, any>;
121
+ randomList: any[];
122
+ binaryTree: BinaryTree;
123
+ }, "id" | "photo" | "bio">, false>;
124
+ declare const TestAppDefinition: AppDefinition;
125
+ declare const ExamplePayloadNullable: _arrirpc_schema.AObjectSchema<{
126
+ string: string | null;
127
+ boolean: boolean | null;
128
+ timestamp: Date | null;
129
+ float32: number | null;
130
+ float64: number | null;
131
+ int8: number | null;
132
+ uint8: number | null;
133
+ int16: number | null;
134
+ uint16: number | null;
135
+ int32: number | null;
136
+ uint32: number | null;
137
+ int64: bigint | null;
138
+ uint64: bigint | null;
139
+ enum: "FOO" | "BAR" | "BAZ" | null;
140
+ object: {
141
+ id: string;
142
+ content: string;
143
+ };
144
+ array: boolean[] | null;
145
+ record: Record<string, boolean> | null;
146
+ any: any;
147
+ }, false>;
148
+ declare const ExampleDiscriminator: _arrirpc_schema.ADiscriminatorSchema<{
149
+ id: string;
150
+ typeName: "A";
151
+ } | {
152
+ id: string;
153
+ name: string;
154
+ typeName: "B";
155
+ } | {
156
+ id: string;
157
+ name: string;
158
+ date: Date;
159
+ typeName: "C";
160
+ }>;
161
+ interface ExampleRecursive {
162
+ left: ExampleRecursive | null;
163
+ right: ExampleRecursive | null;
164
+ }
165
+ declare const ExampleRecursive: _arrirpc_schema.AObjectSchema<ExampleRecursive, false> | _arrirpc_schema.ADiscriminatorSchema<ExampleRecursive>;
166
+ declare const ReferenceAppDefinition: AppDefinition;
167
+
168
+ export { ExampleDiscriminator, ExamplePayloadNullable, ExampleRecursive, ReferenceAppDefinition, TestAppDefinition, TestUpdateUserParams, TestUserNotificationSchema, TestUserParams, TestUserPhotoSchema, TestUserSchema, TestUserSettingsSchema };
@@ -0,0 +1,229 @@
1
+ import { a } from '@arrirpc/schema';
2
+
3
+ const TestUserSettingsSchema = a.object("UserSettings", {
4
+ notificationsEnabled: a.boolean(),
5
+ preferredTheme: a.stringEnum(["dark-mode", "light-mode", "system"], {
6
+ isDeprecated: true
7
+ })
8
+ });
9
+ const TestUserPhotoSchema = a.object(
10
+ {
11
+ url: a.string(),
12
+ width: a.number(),
13
+ height: a.number(),
14
+ bytes: a.int64(),
15
+ nanoseconds: a.uint64({
16
+ description: "When the photo was last updated in nanoseconds"
17
+ })
18
+ },
19
+ { id: "UserPhoto", description: "A profile picture" }
20
+ );
21
+ const TestUserNotificationSchema = a.discriminator(
22
+ "UserNotification",
23
+ "notificationType",
24
+ {
25
+ POST_LIKE: a.object({
26
+ postId: a.string(),
27
+ userId: a.string()
28
+ }),
29
+ POST_COMMENT: a.object({
30
+ postId: a.string(),
31
+ userId: a.string(),
32
+ commentText: a.string()
33
+ })
34
+ }
35
+ );
36
+ const TestUserSchema = a.object("User", {
37
+ id: a.string(),
38
+ role: a.stringEnum(["standard", "admin"]),
39
+ photo: a.nullable(TestUserPhotoSchema),
40
+ createdAt: a.timestamp(),
41
+ numFollowers: a.int32(),
42
+ settings: TestUserSettingsSchema,
43
+ lastNotification: a.nullable(TestUserNotificationSchema),
44
+ recentNotifications: a.array(TestUserNotificationSchema),
45
+ bookmarks: a.record(a.object({ postId: a.string(), userId: a.string() })),
46
+ bio: a.optional(a.string()),
47
+ metadata: a.record(a.any()),
48
+ randomList: a.array(a.any()),
49
+ binaryTree: a.recursive(
50
+ (self) => a.object({
51
+ left: a.nullable(self),
52
+ right: a.nullable(self)
53
+ }),
54
+ { id: "BinaryTree" }
55
+ )
56
+ });
57
+ const TestUserParams = a.object("UserParams", {
58
+ userId: a.string()
59
+ });
60
+ const TestUpdateUserParams = a.pick(
61
+ TestUserSchema,
62
+ ["id", "bio", "photo"],
63
+ {
64
+ id: "UpdateUserParams"
65
+ }
66
+ );
67
+ const TestAppDefinition = {
68
+ arriSchemaVersion: "0.0.5",
69
+ info: {
70
+ title: "Test App Client",
71
+ description: "This is a example app definition",
72
+ version: "11"
73
+ },
74
+ procedures: {
75
+ getStatus: {
76
+ transport: "http",
77
+ path: "/status",
78
+ method: "get",
79
+ params: void 0,
80
+ response: "GetStatusResponse"
81
+ },
82
+ "users.getUser": {
83
+ transport: "http",
84
+ path: "/users/get-user",
85
+ method: "get",
86
+ params: "UserParams",
87
+ response: "User",
88
+ description: "Get a user by id"
89
+ },
90
+ "users.updateUser": {
91
+ transport: "http",
92
+ path: "/users/update-user",
93
+ method: "post",
94
+ params: "UpdateUserParams",
95
+ response: "User",
96
+ description: "Update a user"
97
+ },
98
+ "users.watchUser": {
99
+ transport: "http",
100
+ path: "/users/watch-user",
101
+ method: "get",
102
+ params: "UserParams",
103
+ response: "User",
104
+ isEventStream: true,
105
+ description: "Watch a user"
106
+ },
107
+ "users.createConnection": {
108
+ transport: "ws",
109
+ path: "/users/create-connection",
110
+ params: "UserParams",
111
+ response: "User"
112
+ },
113
+ "users.settings.getUserSettings": {
114
+ transport: "http",
115
+ path: "/users/settings/get-user-settings",
116
+ method: "get",
117
+ params: void 0,
118
+ response: void 0,
119
+ isDeprecated: true
120
+ }
121
+ },
122
+ definitions: {
123
+ GetStatusResponse: a.object({
124
+ message: a.string()
125
+ }),
126
+ User: TestUserSchema,
127
+ UserParams: TestUserParams,
128
+ UpdateUserParams: TestUpdateUserParams
129
+ }
130
+ };
131
+ const ExampleEnum = a.enumerator(["FOO", "BAR", "BAZ"], { id: "ExampleEnum" });
132
+ const ExampleObject = a.object(
133
+ {
134
+ id: a.string(),
135
+ content: a.string()
136
+ },
137
+ {
138
+ id: "ExampleObject"
139
+ }
140
+ );
141
+ const ExamplePayload = a.object(
142
+ {
143
+ string: a.string(),
144
+ boolean: a.boolean(),
145
+ timestamp: a.timestamp(),
146
+ float32: a.float32(),
147
+ float64: a.float64(),
148
+ int8: a.int8(),
149
+ uint8: a.uint8(),
150
+ int16: a.int16(),
151
+ uint16: a.uint16(),
152
+ int32: a.int32(),
153
+ uint32: a.uint32(),
154
+ int64: a.int64(),
155
+ uint64: a.uint64(),
156
+ enum: ExampleEnum,
157
+ object: ExampleObject,
158
+ array: a.array(a.boolean()),
159
+ record: a.record(a.boolean()),
160
+ any: a.any()
161
+ },
162
+ {
163
+ id: "ExamplePayload"
164
+ }
165
+ );
166
+ const ExamplePayloadNullable = a.object(
167
+ {
168
+ string: a.nullable(a.string()),
169
+ boolean: a.nullable(a.boolean()),
170
+ timestamp: a.nullable(a.timestamp()),
171
+ float32: a.nullable(a.float32()),
172
+ float64: a.nullable(a.float64()),
173
+ int8: a.nullable(a.int8()),
174
+ uint8: a.nullable(a.uint8()),
175
+ int16: a.nullable(a.int16()),
176
+ uint16: a.nullable(a.uint16()),
177
+ int32: a.nullable(a.int32()),
178
+ uint32: a.nullable(a.uint32()),
179
+ int64: a.nullable(a.int64()),
180
+ uint64: a.nullable(a.uint64()),
181
+ enum: a.nullable(ExampleEnum),
182
+ object: ExampleObject,
183
+ array: a.nullable(a.array(a.boolean())),
184
+ record: a.nullable(a.record(a.boolean())),
185
+ any: a.nullable(a.any())
186
+ },
187
+ {
188
+ id: "ExamplePayloadNullable"
189
+ }
190
+ );
191
+ const ExampleDiscriminator = a.discriminator(
192
+ "typeName",
193
+ {
194
+ A: a.object({
195
+ id: a.string()
196
+ }),
197
+ B: a.object({
198
+ id: a.string(),
199
+ name: a.string()
200
+ }),
201
+ C: a.object({
202
+ id: a.string(),
203
+ name: a.string(),
204
+ date: a.timestamp()
205
+ })
206
+ },
207
+ {
208
+ id: "ExampleDiscriminator"
209
+ }
210
+ );
211
+ const ExampleRecursive = a.recursive(
212
+ (self) => a.object({
213
+ left: a.nullable(self),
214
+ right: a.nullable(self)
215
+ }),
216
+ { id: "ExampleRecursive" }
217
+ );
218
+ const ReferenceAppDefinition = {
219
+ arriSchemaVersion: "0.0.5",
220
+ procedures: {},
221
+ definitions: {
222
+ ExamplePayload,
223
+ ExamplePayloadNullable,
224
+ ExampleDiscriminator,
225
+ BinaryTree: ExampleRecursive
226
+ }
227
+ };
228
+
229
+ export { ExampleDiscriminator, ExamplePayloadNullable, ExampleRecursive, ReferenceAppDefinition, TestAppDefinition, TestUpdateUserParams, TestUserNotificationSchema, TestUserParams, TestUserPhotoSchema, TestUserSchema, TestUserSettingsSchema };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@arrirpc/codegen-utils",
3
+ "version": "0.45.0",
4
+ "license": "MIT",
5
+ "author": {
6
+ "name": "joshmossas",
7
+ "url": "https://github.com/joshmossas"
8
+ },
9
+ "bugs": {
10
+ "url": "https://github.com/modiimedia/arri/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/modiimedia/arri.git",
15
+ "directory": "tooling/codegen-utils"
16
+ },
17
+ "type": "module",
18
+ "main": "./dist/index.cjs",
19
+ "module": "./dist/index.mjs",
20
+ "types": "./dist/index.d.ts",
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "dependencies": {
25
+ "scule": "^1.3.0",
26
+ "@arrirpc/schema": "0.45.0",
27
+ "jtd-utils": "0.45.0"
28
+ }
29
+ }