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