@darco2903/cdn-api 1.0.7-beta.0 → 1.0.7-beta.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.
Files changed (71) hide show
  1. package/README.md +49 -9
  2. package/dist/client.d.ts +1039 -0
  3. package/{src/client.ts → dist/client.js} +15 -18
  4. package/{src/common.ts → dist/common.d.ts} +4 -4
  5. package/dist/common.js +4 -0
  6. package/dist/consts.d.ts +5 -0
  7. package/{src/consts.ts → dist/consts.js} +4 -8
  8. package/dist/contract/auth.d.ts +35 -0
  9. package/{src/contract/auth.ts → dist/contract/auth.js} +18 -22
  10. package/dist/contract/endpoint.d.ts +396 -0
  11. package/{src/contract/endpoint.ts → dist/contract/endpoint.js} +42 -53
  12. package/dist/contract/index.d.ts +2039 -0
  13. package/{src/contract/index.ts → dist/contract/index.js} +22 -27
  14. package/dist/contract/key.d.ts +15 -0
  15. package/{src/contract/key.ts → dist/contract/key.js} +15 -19
  16. package/dist/contract/list.d.ts +134 -0
  17. package/{src/contract/list.ts → dist/contract/list.js} +28 -30
  18. package/dist/contract/record.d.ts +412 -0
  19. package/{src/contract/record.ts → dist/contract/record.js} +71 -82
  20. package/dist/contract/service.d.ts +240 -0
  21. package/{src/contract/service.ts → dist/contract/service.js} +33 -44
  22. package/dist/contract/stats.d.ts +32 -0
  23. package/{src/contract/stats.ts → dist/contract/stats.js} +34 -36
  24. package/dist/contract/upload.d.ts +790 -0
  25. package/{src/contract/upload.ts → dist/contract/upload.js} +78 -82
  26. package/{src/index.ts → dist/index.d.ts} +2 -2
  27. package/dist/index.js +2 -0
  28. package/dist/server.d.ts +10 -0
  29. package/dist/server.js +58 -0
  30. package/{src/socket/index.ts → dist/socket/index.d.ts} +2 -2
  31. package/dist/socket/index.js +2 -0
  32. package/dist/socket/interface/index.d.ts +5 -0
  33. package/dist/socket/interface/index.js +1 -0
  34. package/{src/socket/interface/template.ts → dist/socket/interface/template.d.ts} +6 -7
  35. package/dist/socket/interface/template.js +1 -0
  36. package/dist/socket/types.d.ts +3 -0
  37. package/dist/socket/types.js +1 -0
  38. package/dist/types/creds.d.ts +8 -0
  39. package/{src/types/creds.ts → dist/types/creds.js} +5 -7
  40. package/dist/types/endpoint.d.ts +25 -0
  41. package/{src/types/endpoint.ts → dist/types/endpoint.js} +12 -19
  42. package/{src/types/index.ts → dist/types/index.d.ts} +6 -6
  43. package/dist/types/index.js +6 -0
  44. package/dist/types/jwt.d.ts +128 -0
  45. package/dist/types/jwt.js +33 -0
  46. package/dist/types/record.d.ts +97 -0
  47. package/{src/types/record.ts → dist/types/record.js} +25 -35
  48. package/dist/types/stats.d.ts +15 -0
  49. package/{src/types/stats.ts → dist/types/stats.js} +6 -9
  50. package/dist/types/upload.d.ts +45 -0
  51. package/{src/types/upload.ts → dist/types/upload.js} +12 -18
  52. package/dist/types.d.ts +32 -0
  53. package/dist/types.js +27 -0
  54. package/dist/uploader.d.ts +1044 -0
  55. package/{src/uploader.ts → dist/uploader.js} +72 -99
  56. package/package.json +2 -2
  57. package/.gitattributes +0 -2
  58. package/.github/workflows/release.yml +0 -116
  59. package/TODO.md +0 -0
  60. package/prettier.config.js +0 -24
  61. package/src/server.ts +0 -89
  62. package/src/socket/interface/index.ts +0 -12
  63. package/src/socket/types.ts +0 -7
  64. package/src/types/jwt.ts +0 -78
  65. package/src/types.ts +0 -38
  66. package/tests/keys/private.pem +0 -5
  67. package/tests/keys/public.pem +0 -4
  68. package/tests/keys.ts +0 -11
  69. package/tests/tsconfig.json +0 -12
  70. package/tests/vitest/jwt.test.ts +0 -38
  71. package/tsconfig.json +0 -14
@@ -0,0 +1,240 @@
1
+ import z from "zod";
2
+ declare const _default: {
3
+ update: {
4
+ body: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
5
+ method: "POST";
6
+ contentType: "multipart/form-data";
7
+ path: "/service/asset";
8
+ headers: z.ZodObject<{
9
+ authorization: z.ZodString;
10
+ }, "strip", z.ZodTypeAny, {
11
+ authorization: string;
12
+ }, {
13
+ authorization: string;
14
+ }>;
15
+ responses: {
16
+ 200: z.ZodType<null, z.ZodTypeDef, null>;
17
+ 400: z.ZodObject<{
18
+ code: z.ZodType<"BAD_REQUEST", z.ZodTypeDef, "BAD_REQUEST">;
19
+ error: z.ZodType<string, z.ZodTypeDef, string>;
20
+ name: z.ZodLiteral<"APIError">;
21
+ }, "strip", z.ZodTypeAny, {
22
+ code: "BAD_REQUEST";
23
+ name: "APIError";
24
+ error: string;
25
+ }, {
26
+ code: "BAD_REQUEST";
27
+ name: "APIError";
28
+ error: string;
29
+ }>;
30
+ 401: z.ZodObject<{
31
+ code: z.ZodType<"UNAUTHORIZED", z.ZodTypeDef, "UNAUTHORIZED">;
32
+ error: z.ZodType<"Invalid CDN token", z.ZodTypeDef, "Invalid CDN token">;
33
+ name: z.ZodLiteral<"APIError">;
34
+ }, "strip", z.ZodTypeAny, {
35
+ code: "UNAUTHORIZED";
36
+ name: "APIError";
37
+ error: "Invalid CDN token";
38
+ }, {
39
+ code: "UNAUTHORIZED";
40
+ name: "APIError";
41
+ error: "Invalid CDN token";
42
+ }>;
43
+ 429: z.ZodObject<{
44
+ code: z.ZodType<"TOO_MANY_REQUESTS", z.ZodTypeDef, "TOO_MANY_REQUESTS">;
45
+ error: z.ZodType<string, z.ZodTypeDef, string>;
46
+ name: z.ZodLiteral<"APIError">;
47
+ }, "strip", z.ZodTypeAny, {
48
+ code: "TOO_MANY_REQUESTS";
49
+ name: "APIError";
50
+ error: string;
51
+ }, {
52
+ code: "TOO_MANY_REQUESTS";
53
+ name: "APIError";
54
+ error: string;
55
+ }>;
56
+ 500: z.ZodObject<{
57
+ code: z.ZodType<"INTERNAL_SERVER_ERROR", z.ZodTypeDef, "INTERNAL_SERVER_ERROR">;
58
+ error: z.ZodType<string, z.ZodTypeDef, string>;
59
+ name: z.ZodLiteral<"APIError">;
60
+ }, "strip", z.ZodTypeAny, {
61
+ code: "INTERNAL_SERVER_ERROR";
62
+ name: "APIError";
63
+ error: string;
64
+ }, {
65
+ code: "INTERNAL_SERVER_ERROR";
66
+ name: "APIError";
67
+ error: string;
68
+ }>;
69
+ };
70
+ };
71
+ delete: {
72
+ method: "DELETE";
73
+ path: "/service/asset";
74
+ headers: z.ZodObject<{
75
+ authorization: z.ZodString;
76
+ }, "strip", z.ZodTypeAny, {
77
+ authorization: string;
78
+ }, {
79
+ authorization: string;
80
+ }>;
81
+ responses: {
82
+ 200: z.ZodType<null, z.ZodTypeDef, null>;
83
+ 400: z.ZodObject<{
84
+ name: z.ZodLiteral<"ZodError">;
85
+ issues: z.ZodArray<z.ZodObject<{
86
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
87
+ message: z.ZodOptional<z.ZodString>;
88
+ code: z.ZodNativeEnum<{
89
+ invalid_type: "invalid_type";
90
+ invalid_literal: "invalid_literal";
91
+ custom: "custom";
92
+ invalid_union: "invalid_union";
93
+ invalid_union_discriminator: "invalid_union_discriminator";
94
+ invalid_enum_value: "invalid_enum_value";
95
+ unrecognized_keys: "unrecognized_keys";
96
+ invalid_arguments: "invalid_arguments";
97
+ invalid_return_type: "invalid_return_type";
98
+ invalid_date: "invalid_date";
99
+ invalid_string: "invalid_string";
100
+ too_small: "too_small";
101
+ too_big: "too_big";
102
+ invalid_intersection_types: "invalid_intersection_types";
103
+ not_multiple_of: "not_multiple_of";
104
+ not_finite: "not_finite";
105
+ }>;
106
+ }, "strip", z.ZodAny, z.objectOutputType<{
107
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
108
+ message: z.ZodOptional<z.ZodString>;
109
+ code: z.ZodNativeEnum<{
110
+ invalid_type: "invalid_type";
111
+ invalid_literal: "invalid_literal";
112
+ custom: "custom";
113
+ invalid_union: "invalid_union";
114
+ invalid_union_discriminator: "invalid_union_discriminator";
115
+ invalid_enum_value: "invalid_enum_value";
116
+ unrecognized_keys: "unrecognized_keys";
117
+ invalid_arguments: "invalid_arguments";
118
+ invalid_return_type: "invalid_return_type";
119
+ invalid_date: "invalid_date";
120
+ invalid_string: "invalid_string";
121
+ too_small: "too_small";
122
+ too_big: "too_big";
123
+ invalid_intersection_types: "invalid_intersection_types";
124
+ not_multiple_of: "not_multiple_of";
125
+ not_finite: "not_finite";
126
+ }>;
127
+ }, z.ZodAny, "strip">, z.objectInputType<{
128
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
129
+ message: z.ZodOptional<z.ZodString>;
130
+ code: z.ZodNativeEnum<{
131
+ invalid_type: "invalid_type";
132
+ invalid_literal: "invalid_literal";
133
+ custom: "custom";
134
+ invalid_union: "invalid_union";
135
+ invalid_union_discriminator: "invalid_union_discriminator";
136
+ invalid_enum_value: "invalid_enum_value";
137
+ unrecognized_keys: "unrecognized_keys";
138
+ invalid_arguments: "invalid_arguments";
139
+ invalid_return_type: "invalid_return_type";
140
+ invalid_date: "invalid_date";
141
+ invalid_string: "invalid_string";
142
+ too_small: "too_small";
143
+ too_big: "too_big";
144
+ invalid_intersection_types: "invalid_intersection_types";
145
+ not_multiple_of: "not_multiple_of";
146
+ not_finite: "not_finite";
147
+ }>;
148
+ }, z.ZodAny, "strip">>, "many">;
149
+ }, "strip", z.ZodTypeAny, {
150
+ name: "ZodError";
151
+ issues: z.objectOutputType<{
152
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
153
+ message: z.ZodOptional<z.ZodString>;
154
+ code: z.ZodNativeEnum<{
155
+ invalid_type: "invalid_type";
156
+ invalid_literal: "invalid_literal";
157
+ custom: "custom";
158
+ invalid_union: "invalid_union";
159
+ invalid_union_discriminator: "invalid_union_discriminator";
160
+ invalid_enum_value: "invalid_enum_value";
161
+ unrecognized_keys: "unrecognized_keys";
162
+ invalid_arguments: "invalid_arguments";
163
+ invalid_return_type: "invalid_return_type";
164
+ invalid_date: "invalid_date";
165
+ invalid_string: "invalid_string";
166
+ too_small: "too_small";
167
+ too_big: "too_big";
168
+ invalid_intersection_types: "invalid_intersection_types";
169
+ not_multiple_of: "not_multiple_of";
170
+ not_finite: "not_finite";
171
+ }>;
172
+ }, z.ZodAny, "strip">[];
173
+ }, {
174
+ name: "ZodError";
175
+ issues: z.objectInputType<{
176
+ path: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>, "many">;
177
+ message: z.ZodOptional<z.ZodString>;
178
+ code: z.ZodNativeEnum<{
179
+ invalid_type: "invalid_type";
180
+ invalid_literal: "invalid_literal";
181
+ custom: "custom";
182
+ invalid_union: "invalid_union";
183
+ invalid_union_discriminator: "invalid_union_discriminator";
184
+ invalid_enum_value: "invalid_enum_value";
185
+ unrecognized_keys: "unrecognized_keys";
186
+ invalid_arguments: "invalid_arguments";
187
+ invalid_return_type: "invalid_return_type";
188
+ invalid_date: "invalid_date";
189
+ invalid_string: "invalid_string";
190
+ too_small: "too_small";
191
+ too_big: "too_big";
192
+ invalid_intersection_types: "invalid_intersection_types";
193
+ not_multiple_of: "not_multiple_of";
194
+ not_finite: "not_finite";
195
+ }>;
196
+ }, z.ZodAny, "strip">[];
197
+ }>;
198
+ 401: z.ZodObject<{
199
+ code: z.ZodType<"UNAUTHORIZED", z.ZodTypeDef, "UNAUTHORIZED">;
200
+ error: z.ZodType<"Invalid CDN token", z.ZodTypeDef, "Invalid CDN token">;
201
+ name: z.ZodLiteral<"APIError">;
202
+ }, "strip", z.ZodTypeAny, {
203
+ code: "UNAUTHORIZED";
204
+ name: "APIError";
205
+ error: "Invalid CDN token";
206
+ }, {
207
+ code: "UNAUTHORIZED";
208
+ name: "APIError";
209
+ error: "Invalid CDN token";
210
+ }>;
211
+ 404: z.ZodObject<{
212
+ code: z.ZodType<"NOT_FOUND", z.ZodTypeDef, "NOT_FOUND">;
213
+ error: z.ZodType<"Service asset not found", z.ZodTypeDef, "Service asset not found">;
214
+ name: z.ZodLiteral<"APIError">;
215
+ }, "strip", z.ZodTypeAny, {
216
+ code: "NOT_FOUND";
217
+ name: "APIError";
218
+ error: "Service asset not found";
219
+ }, {
220
+ code: "NOT_FOUND";
221
+ name: "APIError";
222
+ error: "Service asset not found";
223
+ }>;
224
+ 500: z.ZodObject<{
225
+ code: z.ZodType<"INTERNAL_SERVER_ERROR", z.ZodTypeDef, "INTERNAL_SERVER_ERROR">;
226
+ error: z.ZodType<string, z.ZodTypeDef, string>;
227
+ name: z.ZodLiteral<"APIError">;
228
+ }, "strip", z.ZodTypeAny, {
229
+ code: "INTERNAL_SERVER_ERROR";
230
+ name: "APIError";
231
+ error: string;
232
+ }, {
233
+ code: "INTERNAL_SERVER_ERROR";
234
+ name: "APIError";
235
+ error: string;
236
+ }>;
237
+ };
238
+ };
239
+ };
240
+ export default _default;
@@ -1,44 +1,33 @@
1
- import { initContract, ZodErrorSchema } from "@ts-rest/core";
2
- import z from "zod";
3
- import { apiError, apiSuccess } from "../types.js";
4
- import { cdnHeaderSchema } from "../types/index.js";
5
-
6
- const c = initContract();
7
-
8
- export default c.router({
9
- update: {
10
- method: "POST",
11
- path: "/service/asset",
12
- headers: cdnHeaderSchema,
13
- contentType: "multipart/form-data",
14
- body: z.object({}),
15
- responses: {
16
- 200: apiSuccess(z.null()),
17
- 400: apiError(z.literal("BAD_REQUEST"), z.string()),
18
- 401: apiError(
19
- z.literal("UNAUTHORIZED"),
20
- z.literal("Invalid CDN token")
21
- ),
22
- 429: apiError(z.literal("TOO_MANY_REQUESTS"), z.string()),
23
- 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
24
- },
25
- },
26
- delete: {
27
- method: "DELETE",
28
- path: "/service/asset",
29
- headers: cdnHeaderSchema,
30
- responses: {
31
- 200: apiSuccess(z.null()),
32
- 400: ZodErrorSchema,
33
- 401: apiError(
34
- z.literal("UNAUTHORIZED"),
35
- z.literal("Invalid CDN token")
36
- ),
37
- 404: apiError(
38
- z.literal("NOT_FOUND"),
39
- z.literal("Service asset not found")
40
- ),
41
- 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
42
- },
43
- },
44
- });
1
+ import { initContract, ZodErrorSchema } from "@ts-rest/core";
2
+ import z from "zod";
3
+ import { apiError, apiSuccess } from "../types.js";
4
+ import { cdnHeaderSchema } from "../types/index.js";
5
+ const c = initContract();
6
+ export default c.router({
7
+ update: {
8
+ method: "POST",
9
+ path: "/service/asset",
10
+ headers: cdnHeaderSchema,
11
+ contentType: "multipart/form-data",
12
+ body: z.object({}),
13
+ responses: {
14
+ 200: apiSuccess(z.null()),
15
+ 400: apiError(z.literal("BAD_REQUEST"), z.string()),
16
+ 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Invalid CDN token")),
17
+ 429: apiError(z.literal("TOO_MANY_REQUESTS"), z.string()),
18
+ 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
19
+ },
20
+ },
21
+ delete: {
22
+ method: "DELETE",
23
+ path: "/service/asset",
24
+ headers: cdnHeaderSchema,
25
+ responses: {
26
+ 200: apiSuccess(z.null()),
27
+ 400: ZodErrorSchema,
28
+ 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Invalid CDN token")),
29
+ 404: apiError(z.literal("NOT_FOUND"), z.literal("Service asset not found")),
30
+ 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
31
+ },
32
+ },
33
+ });
@@ -0,0 +1,32 @@
1
+ import z from "zod";
2
+ declare const _default: {
3
+ global: {
4
+ method: "GET";
5
+ path: "/stats";
6
+ responses: {
7
+ 200: z.ZodType<{
8
+ record_count: number;
9
+ total_size: number;
10
+ max_size: number;
11
+ }, z.ZodTypeDef, {
12
+ record_count: number;
13
+ total_size: number;
14
+ max_size: number;
15
+ }>;
16
+ 500: z.ZodObject<{
17
+ code: z.ZodType<"INTERNAL_SERVER_ERROR", z.ZodTypeDef, "INTERNAL_SERVER_ERROR">;
18
+ error: z.ZodType<string, z.ZodTypeDef, string>;
19
+ name: z.ZodLiteral<"APIError">;
20
+ }, "strip", z.ZodTypeAny, {
21
+ code: "INTERNAL_SERVER_ERROR";
22
+ name: "APIError";
23
+ error: string;
24
+ }, {
25
+ code: "INTERNAL_SERVER_ERROR";
26
+ name: "APIError";
27
+ error: string;
28
+ }>;
29
+ };
30
+ };
31
+ };
32
+ export default _default;
@@ -1,36 +1,34 @@
1
- import { initContract } from "@ts-rest/core";
2
- import z from "zod";
3
- import { apiError, apiSuccess } from "../types.js";
4
- import { statsGlobalSchema } from "../types/index.js";
5
-
6
- const c = initContract();
7
-
8
- export default c.router({
9
- global: {
10
- method: "GET",
11
- path: "/stats",
12
- responses: {
13
- 200: apiSuccess(statsGlobalSchema),
14
- 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
15
- },
16
- },
17
- // globalAdmin: {
18
- // method: "GET",
19
- // path: "/stats/admin",
20
- // responses: {
21
- // 200: apiSuccess(statsGlobalSchema),
22
- // 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
23
- // 403: apiError(z.literal("FORBIDDEN"), z.literal("Forbidden")),
24
- // 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
25
- // },
26
- // },
27
- // user: {
28
- // method: "GET",
29
- // path: "/stats/:public_id",
30
- // headers: authHeaderSchema,
31
- // responses: {
32
- // 200: apiSuccess(statsGlobalSchema),
33
- // 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
34
- // },
35
- // },
36
- });
1
+ import { initContract } from "@ts-rest/core";
2
+ import z from "zod";
3
+ import { apiError, apiSuccess } from "../types.js";
4
+ import { statsGlobalSchema } from "../types/index.js";
5
+ const c = initContract();
6
+ export default c.router({
7
+ global: {
8
+ method: "GET",
9
+ path: "/stats",
10
+ responses: {
11
+ 200: apiSuccess(statsGlobalSchema),
12
+ 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
13
+ },
14
+ },
15
+ // globalAdmin: {
16
+ // method: "GET",
17
+ // path: "/stats/admin",
18
+ // responses: {
19
+ // 200: apiSuccess(statsGlobalSchema),
20
+ // 401: apiError(z.literal("UNAUTHORIZED"), z.literal("Unauthorized")),
21
+ // 403: apiError(z.literal("FORBIDDEN"), z.literal("Forbidden")),
22
+ // 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
23
+ // },
24
+ // },
25
+ // user: {
26
+ // method: "GET",
27
+ // path: "/stats/:public_id",
28
+ // headers: authHeaderSchema,
29
+ // responses: {
30
+ // 200: apiSuccess(statsGlobalSchema),
31
+ // 500: apiError(z.literal("INTERNAL_SERVER_ERROR"), z.string()),
32
+ // },
33
+ // },
34
+ });