@ai0x0/utils 0.0.0

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 (122) hide show
  1. package/LICENSE +21 -0
  2. package/es/backend/actions/delete-action-fn.d.ts +7 -0
  3. package/es/backend/actions/delete-action-fn.d.ts.map +1 -0
  4. package/es/backend/actions/delete-action-fn.js +30 -0
  5. package/es/backend/actions/get-List-query.d.ts +30 -0
  6. package/es/backend/actions/get-List-query.d.ts.map +1 -0
  7. package/es/backend/actions/get-List-query.js +212 -0
  8. package/es/backend/actions/get-action-fn.d.ts +12 -0
  9. package/es/backend/actions/get-action-fn.d.ts.map +1 -0
  10. package/es/backend/actions/get-action-fn.js +75 -0
  11. package/es/backend/actions/get-list-action-fn.d.ts +12 -0
  12. package/es/backend/actions/get-list-action-fn.d.ts.map +1 -0
  13. package/es/backend/actions/get-list-action-fn.js +68 -0
  14. package/es/backend/actions/get-list-data.d.ts +8 -0
  15. package/es/backend/actions/get-list-data.d.ts.map +1 -0
  16. package/es/backend/actions/get-list-data.js +49 -0
  17. package/es/backend/actions/index.d.ts +6 -0
  18. package/es/backend/actions/index.d.ts.map +1 -0
  19. package/es/backend/actions/index.js +5 -0
  20. package/es/backend/actions/post-action-fn.d.ts +13 -0
  21. package/es/backend/actions/post-action-fn.d.ts.map +1 -0
  22. package/es/backend/actions/post-action-fn.js +35 -0
  23. package/es/backend/actions/put-action-fn.d.ts +9 -0
  24. package/es/backend/actions/put-action-fn.d.ts.map +1 -0
  25. package/es/backend/actions/put-action-fn.js +34 -0
  26. package/es/backend/actions/transform-body.d.ts +2 -0
  27. package/es/backend/actions/transform-body.d.ts.map +1 -0
  28. package/es/backend/actions/transform-body.js +11 -0
  29. package/es/backend/index.d.ts +3 -0
  30. package/es/backend/index.d.ts.map +1 -0
  31. package/es/backend/index.js +2 -0
  32. package/es/backend/route-operation/delete-operation.d.ts +10 -0
  33. package/es/backend/route-operation/delete-operation.d.ts.map +1 -0
  34. package/es/backend/route-operation/delete-operation.js +59 -0
  35. package/es/backend/route-operation/get-list-operation.d.ts +24 -0
  36. package/es/backend/route-operation/get-list-operation.d.ts.map +1 -0
  37. package/es/backend/route-operation/get-list-operation.js +83 -0
  38. package/es/backend/route-operation/get-operation.d.ts +17 -0
  39. package/es/backend/route-operation/get-operation.d.ts.map +1 -0
  40. package/es/backend/route-operation/get-operation.js +65 -0
  41. package/es/backend/route-operation/get-table-name.d.ts +4 -0
  42. package/es/backend/route-operation/get-table-name.d.ts.map +1 -0
  43. package/es/backend/route-operation/get-table-name.js +13 -0
  44. package/es/backend/route-operation/index.d.ts +6 -0
  45. package/es/backend/route-operation/index.d.ts.map +1 -0
  46. package/es/backend/route-operation/index.js +5 -0
  47. package/es/backend/route-operation/post-operation.d.ts +14 -0
  48. package/es/backend/route-operation/post-operation.d.ts.map +1 -0
  49. package/es/backend/route-operation/post-operation.js +84 -0
  50. package/es/backend/route-operation/put-operation.d.ts +14 -0
  51. package/es/backend/route-operation/put-operation.d.ts.map +1 -0
  52. package/es/backend/route-operation/put-operation.js +71 -0
  53. package/es/backend/schemas/index.d.ts +4674 -0
  54. package/es/backend/schemas/index.d.ts.map +1 -0
  55. package/es/backend/schemas/index.js +87 -0
  56. package/es/backend/types.d.ts +13 -0
  57. package/es/backend/types.d.ts.map +1 -0
  58. package/es/backend/types.js +1 -0
  59. package/es/index.d.ts +1 -0
  60. package/es/index.d.ts.map +1 -0
  61. package/es/index.js +0 -0
  62. package/lib/backend/actions/delete-action-fn.d.ts +7 -0
  63. package/lib/backend/actions/delete-action-fn.d.ts.map +1 -0
  64. package/lib/backend/actions/delete-action-fn.js +42 -0
  65. package/lib/backend/actions/get-List-query.d.ts +30 -0
  66. package/lib/backend/actions/get-List-query.d.ts.map +1 -0
  67. package/lib/backend/actions/get-List-query.js +162 -0
  68. package/lib/backend/actions/get-action-fn.d.ts +12 -0
  69. package/lib/backend/actions/get-action-fn.d.ts.map +1 -0
  70. package/lib/backend/actions/get-action-fn.js +75 -0
  71. package/lib/backend/actions/get-list-action-fn.d.ts +12 -0
  72. package/lib/backend/actions/get-list-action-fn.d.ts.map +1 -0
  73. package/lib/backend/actions/get-list-action-fn.js +74 -0
  74. package/lib/backend/actions/get-list-data.d.ts +8 -0
  75. package/lib/backend/actions/get-list-data.d.ts.map +1 -0
  76. package/lib/backend/actions/get-list-data.js +48 -0
  77. package/lib/backend/actions/index.d.ts +6 -0
  78. package/lib/backend/actions/index.d.ts.map +1 -0
  79. package/lib/backend/actions/index.js +41 -0
  80. package/lib/backend/actions/post-action-fn.d.ts +13 -0
  81. package/lib/backend/actions/post-action-fn.d.ts.map +1 -0
  82. package/lib/backend/actions/post-action-fn.js +49 -0
  83. package/lib/backend/actions/put-action-fn.d.ts +9 -0
  84. package/lib/backend/actions/put-action-fn.d.ts.map +1 -0
  85. package/lib/backend/actions/put-action-fn.js +43 -0
  86. package/lib/backend/actions/transform-body.d.ts +2 -0
  87. package/lib/backend/actions/transform-body.d.ts.map +1 -0
  88. package/lib/backend/actions/transform-body.js +47 -0
  89. package/lib/backend/index.d.ts +3 -0
  90. package/lib/backend/index.d.ts.map +1 -0
  91. package/lib/backend/index.js +25 -0
  92. package/lib/backend/route-operation/delete-operation.d.ts +10 -0
  93. package/lib/backend/route-operation/delete-operation.d.ts.map +1 -0
  94. package/lib/backend/route-operation/delete-operation.js +59 -0
  95. package/lib/backend/route-operation/get-list-operation.d.ts +24 -0
  96. package/lib/backend/route-operation/get-list-operation.d.ts.map +1 -0
  97. package/lib/backend/route-operation/get-list-operation.js +87 -0
  98. package/lib/backend/route-operation/get-operation.d.ts +17 -0
  99. package/lib/backend/route-operation/get-operation.d.ts.map +1 -0
  100. package/lib/backend/route-operation/get-operation.js +82 -0
  101. package/lib/backend/route-operation/get-table-name.d.ts +4 -0
  102. package/lib/backend/route-operation/get-table-name.d.ts.map +1 -0
  103. package/lib/backend/route-operation/get-table-name.js +35 -0
  104. package/lib/backend/route-operation/index.d.ts +6 -0
  105. package/lib/backend/route-operation/index.d.ts.map +1 -0
  106. package/lib/backend/route-operation/index.js +31 -0
  107. package/lib/backend/route-operation/post-operation.d.ts +14 -0
  108. package/lib/backend/route-operation/post-operation.d.ts.map +1 -0
  109. package/lib/backend/route-operation/post-operation.js +67 -0
  110. package/lib/backend/route-operation/put-operation.d.ts +14 -0
  111. package/lib/backend/route-operation/put-operation.d.ts.map +1 -0
  112. package/lib/backend/route-operation/put-operation.js +66 -0
  113. package/lib/backend/schemas/index.d.ts +4674 -0
  114. package/lib/backend/schemas/index.d.ts.map +1 -0
  115. package/lib/backend/schemas/index.js +98 -0
  116. package/lib/backend/types.d.ts +13 -0
  117. package/lib/backend/types.d.ts.map +1 -0
  118. package/lib/backend/types.js +17 -0
  119. package/lib/index.d.ts +1 -0
  120. package/lib/index.d.ts.map +1 -0
  121. package/lib/index.js +0 -0
  122. package/package.json +86 -0
@@ -0,0 +1,14 @@
1
+ import { z, ZodSchema } from "zod";
2
+ import { PgTable } from "drizzle-orm/pg-core";
3
+ import { NextRequest } from "next/server";
4
+ import { NodePgDatabase } from "drizzle-orm/node-postgres";
5
+ export interface PostOperationOptions<T extends ZodSchema, TTable extends PgTable> {
6
+ bodySchema: T;
7
+ setBody?: (req: NextRequest) => Promise<Partial<z.infer<T>>>;
8
+ summary?: string;
9
+ table: TTable;
10
+ }
11
+ export declare const createPostOperation: <T extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends PgTable<import("drizzle-orm/pg-core").TableConfig>>({ db, }: {
12
+ db: NodePgDatabase<any>;
13
+ }) => ({ bodySchema, setBody, summary, table }: PostOperationOptions<T, TTable>) => any;
14
+ //# sourceMappingURL=post-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-operation.d.ts","sourceRoot":"","sources":["post-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,WAAW,oBAAoB,CACnC,CAAC,SAAS,SAAS,EACnB,MAAM,SAAS,OAAO;IAEtB,UAAU,EAAE,CAAC,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,mBAAmB;QAIxB,eAAe,GAAG,CAAC;uFA4BZ,CAAC"}
@@ -0,0 +1,67 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/backend/route-operation/post-operation.ts
30
+ var post_operation_exports = {};
31
+ __export(post_operation_exports, {
32
+ createPostOperation: () => createPostOperation
33
+ });
34
+ module.exports = __toCommonJS(post_operation_exports);
35
+ var import_zod = require("zod");
36
+ var import_next_rest_framework = require("next-rest-framework");
37
+ var import_get_table_name = __toESM(require("./get-table-name"));
38
+ var import_actions = require("../actions");
39
+ var createPostOperation = ({
40
+ db
41
+ }) => ({ bodySchema, setBody, summary, table }) => (0, import_next_rest_framework.routeOperation)({
42
+ method: "POST",
43
+ openApiOperation: {
44
+ summary,
45
+ tags: [(0, import_get_table_name.default)(table)]
46
+ }
47
+ }).input({
48
+ body: bodySchema,
49
+ contentType: "application/json"
50
+ }).outputs([
51
+ {
52
+ body: import_zod.z.object({ id: import_zod.z.string() }),
53
+ contentType: "application/json",
54
+ status: 200
55
+ }
56
+ ]).handler(async (req) => {
57
+ const body = Object.assign(
58
+ await (setBody == null ? void 0 : setBody(req)) || {},
59
+ await req.json()
60
+ );
61
+ const [data] = await (0, import_actions.postActionFn)({ bodySchema, db, table })(body);
62
+ return import_next_rest_framework.TypedNextResponse.json(data, { status: 200 });
63
+ });
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ createPostOperation
67
+ });
@@ -0,0 +1,14 @@
1
+ import { z, ZodSchema } from "zod";
2
+ import { PgTable } from "drizzle-orm/pg-core";
3
+ import { NodePgDatabase } from "drizzle-orm/node-postgres";
4
+ import { NextRequest } from "next/server";
5
+ export interface PutOperationOptions<T extends ZodSchema, TTable extends PgTable> {
6
+ bodySchema: T;
7
+ table: TTable;
8
+ summary?: string;
9
+ setBody?: (req: NextRequest) => Promise<Partial<z.infer<T>>>;
10
+ }
11
+ export declare const createPutOperation: <T extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends PgTable<import("drizzle-orm/pg-core").TableConfig>>({ db, }: {
12
+ db: NodePgDatabase<any>;
13
+ }) => ({ bodySchema, table, summary, setBody }: PutOperationOptions<T, TTable>) => any;
14
+ //# sourceMappingURL=put-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"put-operation.d.ts","sourceRoot":"","sources":["put-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAI9C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,mBAAmB,CAClC,CAAC,SAAS,SAAS,EACnB,MAAM,SAAS,OAAO;IAEtB,UAAU,EAAE,CAAC,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9D;AAED,eAAO,MAAM,kBAAkB;QAIvB,eAAe,GAAG,CAAC;sFA2BZ,CAAC"}
@@ -0,0 +1,66 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/backend/route-operation/put-operation.ts
30
+ var put_operation_exports = {};
31
+ __export(put_operation_exports, {
32
+ createPutOperation: () => createPutOperation
33
+ });
34
+ module.exports = __toCommonJS(put_operation_exports);
35
+ var import_next_rest_framework = require("next-rest-framework");
36
+ var import_get_table_name = __toESM(require("./get-table-name"));
37
+ var import_actions = require("../actions");
38
+ var createPutOperation = ({
39
+ db
40
+ }) => ({ bodySchema, table, summary, setBody }) => (0, import_next_rest_framework.routeOperation)({
41
+ method: "PUT",
42
+ openApiOperation: {
43
+ summary,
44
+ tags: [(0, import_get_table_name.default)(table)]
45
+ }
46
+ }).input({
47
+ body: bodySchema,
48
+ contentType: "application/json"
49
+ }).handler(async (req) => {
50
+ const body = Object.assign(
51
+ await (setBody == null ? void 0 : setBody(req)) || {},
52
+ await req.json()
53
+ );
54
+ return import_next_rest_framework.TypedNextResponse.json(
55
+ await (0, import_actions.putActionFn)({
56
+ bodySchema,
57
+ table,
58
+ db
59
+ })(body),
60
+ { status: 200 }
61
+ );
62
+ });
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ createPutOperation
66
+ });