@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.
- package/LICENSE +21 -0
- package/es/backend/actions/delete-action-fn.d.ts +7 -0
- package/es/backend/actions/delete-action-fn.d.ts.map +1 -0
- package/es/backend/actions/delete-action-fn.js +30 -0
- package/es/backend/actions/get-List-query.d.ts +30 -0
- package/es/backend/actions/get-List-query.d.ts.map +1 -0
- package/es/backend/actions/get-List-query.js +212 -0
- package/es/backend/actions/get-action-fn.d.ts +12 -0
- package/es/backend/actions/get-action-fn.d.ts.map +1 -0
- package/es/backend/actions/get-action-fn.js +75 -0
- package/es/backend/actions/get-list-action-fn.d.ts +12 -0
- package/es/backend/actions/get-list-action-fn.d.ts.map +1 -0
- package/es/backend/actions/get-list-action-fn.js +68 -0
- package/es/backend/actions/get-list-data.d.ts +8 -0
- package/es/backend/actions/get-list-data.d.ts.map +1 -0
- package/es/backend/actions/get-list-data.js +49 -0
- package/es/backend/actions/index.d.ts +6 -0
- package/es/backend/actions/index.d.ts.map +1 -0
- package/es/backend/actions/index.js +5 -0
- package/es/backend/actions/post-action-fn.d.ts +13 -0
- package/es/backend/actions/post-action-fn.d.ts.map +1 -0
- package/es/backend/actions/post-action-fn.js +35 -0
- package/es/backend/actions/put-action-fn.d.ts +9 -0
- package/es/backend/actions/put-action-fn.d.ts.map +1 -0
- package/es/backend/actions/put-action-fn.js +34 -0
- package/es/backend/actions/transform-body.d.ts +2 -0
- package/es/backend/actions/transform-body.d.ts.map +1 -0
- package/es/backend/actions/transform-body.js +11 -0
- package/es/backend/index.d.ts +3 -0
- package/es/backend/index.d.ts.map +1 -0
- package/es/backend/index.js +2 -0
- package/es/backend/route-operation/delete-operation.d.ts +10 -0
- package/es/backend/route-operation/delete-operation.d.ts.map +1 -0
- package/es/backend/route-operation/delete-operation.js +59 -0
- package/es/backend/route-operation/get-list-operation.d.ts +24 -0
- package/es/backend/route-operation/get-list-operation.d.ts.map +1 -0
- package/es/backend/route-operation/get-list-operation.js +83 -0
- package/es/backend/route-operation/get-operation.d.ts +17 -0
- package/es/backend/route-operation/get-operation.d.ts.map +1 -0
- package/es/backend/route-operation/get-operation.js +65 -0
- package/es/backend/route-operation/get-table-name.d.ts +4 -0
- package/es/backend/route-operation/get-table-name.d.ts.map +1 -0
- package/es/backend/route-operation/get-table-name.js +13 -0
- package/es/backend/route-operation/index.d.ts +6 -0
- package/es/backend/route-operation/index.d.ts.map +1 -0
- package/es/backend/route-operation/index.js +5 -0
- package/es/backend/route-operation/post-operation.d.ts +14 -0
- package/es/backend/route-operation/post-operation.d.ts.map +1 -0
- package/es/backend/route-operation/post-operation.js +84 -0
- package/es/backend/route-operation/put-operation.d.ts +14 -0
- package/es/backend/route-operation/put-operation.d.ts.map +1 -0
- package/es/backend/route-operation/put-operation.js +71 -0
- package/es/backend/schemas/index.d.ts +4674 -0
- package/es/backend/schemas/index.d.ts.map +1 -0
- package/es/backend/schemas/index.js +87 -0
- package/es/backend/types.d.ts +13 -0
- package/es/backend/types.d.ts.map +1 -0
- package/es/backend/types.js +1 -0
- package/es/index.d.ts +1 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +0 -0
- package/lib/backend/actions/delete-action-fn.d.ts +7 -0
- package/lib/backend/actions/delete-action-fn.d.ts.map +1 -0
- package/lib/backend/actions/delete-action-fn.js +42 -0
- package/lib/backend/actions/get-List-query.d.ts +30 -0
- package/lib/backend/actions/get-List-query.d.ts.map +1 -0
- package/lib/backend/actions/get-List-query.js +162 -0
- package/lib/backend/actions/get-action-fn.d.ts +12 -0
- package/lib/backend/actions/get-action-fn.d.ts.map +1 -0
- package/lib/backend/actions/get-action-fn.js +75 -0
- package/lib/backend/actions/get-list-action-fn.d.ts +12 -0
- package/lib/backend/actions/get-list-action-fn.d.ts.map +1 -0
- package/lib/backend/actions/get-list-action-fn.js +74 -0
- package/lib/backend/actions/get-list-data.d.ts +8 -0
- package/lib/backend/actions/get-list-data.d.ts.map +1 -0
- package/lib/backend/actions/get-list-data.js +48 -0
- package/lib/backend/actions/index.d.ts +6 -0
- package/lib/backend/actions/index.d.ts.map +1 -0
- package/lib/backend/actions/index.js +41 -0
- package/lib/backend/actions/post-action-fn.d.ts +13 -0
- package/lib/backend/actions/post-action-fn.d.ts.map +1 -0
- package/lib/backend/actions/post-action-fn.js +49 -0
- package/lib/backend/actions/put-action-fn.d.ts +9 -0
- package/lib/backend/actions/put-action-fn.d.ts.map +1 -0
- package/lib/backend/actions/put-action-fn.js +43 -0
- package/lib/backend/actions/transform-body.d.ts +2 -0
- package/lib/backend/actions/transform-body.d.ts.map +1 -0
- package/lib/backend/actions/transform-body.js +47 -0
- package/lib/backend/index.d.ts +3 -0
- package/lib/backend/index.d.ts.map +1 -0
- package/lib/backend/index.js +25 -0
- package/lib/backend/route-operation/delete-operation.d.ts +10 -0
- package/lib/backend/route-operation/delete-operation.d.ts.map +1 -0
- package/lib/backend/route-operation/delete-operation.js +59 -0
- package/lib/backend/route-operation/get-list-operation.d.ts +24 -0
- package/lib/backend/route-operation/get-list-operation.d.ts.map +1 -0
- package/lib/backend/route-operation/get-list-operation.js +87 -0
- package/lib/backend/route-operation/get-operation.d.ts +17 -0
- package/lib/backend/route-operation/get-operation.d.ts.map +1 -0
- package/lib/backend/route-operation/get-operation.js +82 -0
- package/lib/backend/route-operation/get-table-name.d.ts +4 -0
- package/lib/backend/route-operation/get-table-name.d.ts.map +1 -0
- package/lib/backend/route-operation/get-table-name.js +35 -0
- package/lib/backend/route-operation/index.d.ts +6 -0
- package/lib/backend/route-operation/index.d.ts.map +1 -0
- package/lib/backend/route-operation/index.js +31 -0
- package/lib/backend/route-operation/post-operation.d.ts +14 -0
- package/lib/backend/route-operation/post-operation.d.ts.map +1 -0
- package/lib/backend/route-operation/post-operation.js +67 -0
- package/lib/backend/route-operation/put-operation.d.ts +14 -0
- package/lib/backend/route-operation/put-operation.d.ts.map +1 -0
- package/lib/backend/route-operation/put-operation.js +66 -0
- package/lib/backend/schemas/index.d.ts +4674 -0
- package/lib/backend/schemas/index.d.ts.map +1 -0
- package/lib/backend/schemas/index.js +98 -0
- package/lib/backend/types.d.ts +13 -0
- package/lib/backend/types.d.ts.map +1 -0
- package/lib/backend/types.js +17 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +0 -0
- package/package.json +86 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;AAClD,OAAO,EACL,mBAAmB,EAEnB,uBAAuB,EAGxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAMtD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAmBhE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;sFAaV,CAAC;AAGnB,eAAO,MAAM,cAAc;;;;;;;;;EAIvB,CAAC;AAGL,eAAO,MAAM,iBAAiB;;;0BAWpB,wBACJ,MAAM,EACN,OAAO,MAAM,EAAE,mBAAmB,CAAC,EACnC,IAAI,CACL,KACE,uBAAuB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgC/B,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { pgTable, timestamp, uuid } from "drizzle-orm/pg-core";
|
|
9
|
+
import { createInsertSchema, createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
10
|
+
//============================基本字段============================//
|
|
11
|
+
var timestamptz = function timestamptz(name) {
|
|
12
|
+
return timestamp(name, {
|
|
13
|
+
withTimezone: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var createdAt = function createdAt() {
|
|
17
|
+
return timestamptz("created_at").notNull().defaultNow();
|
|
18
|
+
};
|
|
19
|
+
var updatedAt = function updatedAt() {
|
|
20
|
+
return timestamptz("updated_at").notNull().defaultNow();
|
|
21
|
+
};
|
|
22
|
+
var accessedAt = function accessedAt() {
|
|
23
|
+
return timestamptz("accessed_at").notNull().defaultNow();
|
|
24
|
+
};
|
|
25
|
+
var basicFields = {
|
|
26
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
27
|
+
creatorId: uuid("creator_id"),
|
|
28
|
+
editorId: uuid("editor_id"),
|
|
29
|
+
accessedAt: accessedAt(),
|
|
30
|
+
createdAt: createdAt(),
|
|
31
|
+
updatedAt: updatedAt()
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//============================列表查询字段============================//
|
|
35
|
+
export var queryListSchema = function queryListSchema(schema) {
|
|
36
|
+
return z.object({
|
|
37
|
+
current: z.string().optional().default("1"),
|
|
38
|
+
// 默认页码为 1
|
|
39
|
+
pageSize: z.string().optional().default("10"),
|
|
40
|
+
// 默认每页条数为 10
|
|
41
|
+
createdAtFrom: z.string().optional(),
|
|
42
|
+
// 筛选开始日期
|
|
43
|
+
createdAtTo: z.string().optional(),
|
|
44
|
+
// 筛选结束日期
|
|
45
|
+
orderBy: z.string().optional(),
|
|
46
|
+
creatorId: z.string().optional(),
|
|
47
|
+
orderDir: z.enum(["asc", "desc"]).optional()
|
|
48
|
+
}).merge(schema);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//============================列表返回字段============================//
|
|
52
|
+
export var listBodySchema = function listBodySchema(schema) {
|
|
53
|
+
return z.object({
|
|
54
|
+
total: z.number(),
|
|
55
|
+
data: z.array(schema)
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//============================创建一个pg表============================//
|
|
60
|
+
export var createTableSchema = function createTableSchema(_ref) {
|
|
61
|
+
var name = _ref.name,
|
|
62
|
+
columns = _ref.columns,
|
|
63
|
+
extraConfig = _ref.extraConfig;
|
|
64
|
+
// 创建表
|
|
65
|
+
var table = pgTable(name, _objectSpread(_objectSpread({}, basicFields), columns), extraConfig);
|
|
66
|
+
// 创建基础的schema
|
|
67
|
+
var selectSchema = createSelectSchema(table);
|
|
68
|
+
return {
|
|
69
|
+
table: table,
|
|
70
|
+
selectSchema: selectSchema,
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
insertSchema: createInsertSchema(table, {}),
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
updateSchema: createUpdateSchema(table, {
|
|
77
|
+
id: z.string()
|
|
78
|
+
}),
|
|
79
|
+
querySchema: selectSchema.pick({
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
id: true
|
|
83
|
+
}),
|
|
84
|
+
queryListSchema: queryListSchema(selectSchema.partial()),
|
|
85
|
+
queryListSelectSchema: selectSchema
|
|
86
|
+
};
|
|
87
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PgColumn, PgTable } from "drizzle-orm/pg-core";
|
|
2
|
+
import { SQL } from "drizzle-orm";
|
|
3
|
+
export interface BaseTable extends PgTable {
|
|
4
|
+
createdAt: PgColumn;
|
|
5
|
+
id: PgColumn;
|
|
6
|
+
}
|
|
7
|
+
export type GetListRelations = {
|
|
8
|
+
groupBy?: boolean;
|
|
9
|
+
select?: Record<string, unknown>;
|
|
10
|
+
sql?: SQL;
|
|
11
|
+
table?: BaseTable;
|
|
12
|
+
}[];
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,MAAM,WAAW,SAAU,SAAQ,OAAO;IACxC,SAAS,EAAE,QAAQ,CAAC;IACpB,EAAE,EAAE,QAAQ,CAAC;CACd;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":""}
|
package/es/index.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
2
|
+
import { BaseTable } from "../types";
|
|
3
|
+
export declare function deleteActionFn<TTable extends BaseTable>({ table, db, }: {
|
|
4
|
+
db: NodePgDatabase<any>;
|
|
5
|
+
table: TTable;
|
|
6
|
+
}): any;
|
|
7
|
+
//# sourceMappingURL=delete-action-fn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-action-fn.d.ts","sourceRoot":"","sources":["delete-action-fn.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,iBAAwB;AAE5C,wBAAgB,cAAc,CAAC,MAAM,SAAS,SAAS,EAAE,EACvD,KAAK,EACL,EAAE,GACH,EAAE;IACD,EAAE,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,OASA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/backend/actions/delete-action-fn.ts
|
|
20
|
+
var delete_action_fn_exports = {};
|
|
21
|
+
__export(delete_action_fn_exports, {
|
|
22
|
+
deleteActionFn: () => deleteActionFn
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(delete_action_fn_exports);
|
|
25
|
+
var import_next_rest_framework = require("next-rest-framework");
|
|
26
|
+
var import_zod = require("zod");
|
|
27
|
+
var import_drizzle_orm = require("drizzle-orm");
|
|
28
|
+
function deleteActionFn({
|
|
29
|
+
table,
|
|
30
|
+
db
|
|
31
|
+
}) {
|
|
32
|
+
return (0, import_next_rest_framework.rpcOperation)().input({
|
|
33
|
+
body: import_zod.z.string(),
|
|
34
|
+
contentType: "application/json"
|
|
35
|
+
}).handler(async (id) => {
|
|
36
|
+
return db.delete(table).where((0, import_drizzle_orm.eq)(table.id, id)).returning();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
deleteActionFn
|
|
42
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseTable, GetListRelations } from "../types";
|
|
2
|
+
import { SelectedFields } from "drizzle-orm/pg-core/query-builders/select.types";
|
|
3
|
+
import { SQL } from "drizzle-orm";
|
|
4
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
|
+
export declare function getListQuery<TTable extends BaseTable, TSelection extends SelectedFields>({ db, fields, jsonArrayFields, params, relations, table, }: {
|
|
6
|
+
db: NodePgDatabase<any>;
|
|
7
|
+
fields: TSelection;
|
|
8
|
+
jsonArrayFields?: string[];
|
|
9
|
+
params: {
|
|
10
|
+
[field: string]: any;
|
|
11
|
+
orderBy?: keyof BaseTable;
|
|
12
|
+
orderDir?: "asc" | "desc";
|
|
13
|
+
page?: number;
|
|
14
|
+
pageSize?: number;
|
|
15
|
+
};
|
|
16
|
+
relations?: GetListRelations;
|
|
17
|
+
table: TTable;
|
|
18
|
+
}): {
|
|
19
|
+
countQuery: Omit<import("drizzle-orm/pg-core").PgSelectBase<any, {
|
|
20
|
+
count: SQL<unknown>;
|
|
21
|
+
}, "partial", {} | Record<any, "not-null">, false, "where", ({
|
|
22
|
+
count: unknown;
|
|
23
|
+
} | {
|
|
24
|
+
count: unknown;
|
|
25
|
+
})[], {
|
|
26
|
+
count: import("drizzle-orm").DrizzleTypeError<"You cannot reference this field without assigning it an alias first - use `.as(<alias>)`">;
|
|
27
|
+
}>, "where">;
|
|
28
|
+
query: any;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=get-List-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-List-query.d.ts","sourceRoot":"","sources":["get-List-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAwB;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;AACjF,OAAO,EAYL,GAAG,EACJ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,wBAAgB,YAAY,CAC1B,MAAM,SAAS,SAAS,EACxB,UAAU,SAAS,cAAc,EACjC,EACA,EAAE,EACF,MAAM,EACN,eAAe,EACf,MAAM,EACN,SAAS,EACT,KAAK,GACN,EAAE;IACD,EAAE,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,MAAM,EAAE;QAEN,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;QAErB,OAAO,CAAC,EAAE,MAAM,SAAS,CAAC;QAE1B,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf;;;;;;;;;;;EA6MA"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc2) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/backend/actions/get-List-query.ts
|
|
20
|
+
var get_List_query_exports = {};
|
|
21
|
+
__export(get_List_query_exports, {
|
|
22
|
+
getListQuery: () => getListQuery
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(get_List_query_exports);
|
|
25
|
+
var import_drizzle_orm = require("drizzle-orm");
|
|
26
|
+
function getListQuery({
|
|
27
|
+
db,
|
|
28
|
+
fields,
|
|
29
|
+
jsonArrayFields,
|
|
30
|
+
params,
|
|
31
|
+
relations,
|
|
32
|
+
table
|
|
33
|
+
}) {
|
|
34
|
+
const {
|
|
35
|
+
page = 1,
|
|
36
|
+
pageSize = 10,
|
|
37
|
+
orderBy = "createdAt",
|
|
38
|
+
orderDir = "desc",
|
|
39
|
+
...filters
|
|
40
|
+
} = params;
|
|
41
|
+
function buildBaseQuery(table2, fields2, relations2) {
|
|
42
|
+
let queryFields = { ...fields2 };
|
|
43
|
+
if (relations2 == null ? void 0 : relations2.length) {
|
|
44
|
+
for (const { select } of relations2) {
|
|
45
|
+
queryFields = { ...queryFields, ...select };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const query2 = db.select(queryFields).from(table2);
|
|
49
|
+
if (relations2 == null ? void 0 : relations2.length) {
|
|
50
|
+
query2.groupBy(
|
|
51
|
+
table2.id,
|
|
52
|
+
...relations2.filter(({ groupBy }) => groupBy).filter(({ table: table3 }) => table3).map(({ table: table3 }) => table3.id)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return query2;
|
|
56
|
+
}
|
|
57
|
+
function findTargetColumn(key, table2, relations2) {
|
|
58
|
+
var _a;
|
|
59
|
+
return (_a = [table2].concat(
|
|
60
|
+
(relations2 == null ? void 0 : relations2.filter(({ table: table3 }) => table3).map(({ table: table3 }) => table3)) || []
|
|
61
|
+
).find((t) => t[key])) == null ? void 0 : _a[key];
|
|
62
|
+
}
|
|
63
|
+
function addCondition(conditions2, key, value, targetColumn) {
|
|
64
|
+
const isIdField = /id/i.test(key);
|
|
65
|
+
const isJsonArray = jsonArrayFields == null ? void 0 : jsonArrayFields.includes(key);
|
|
66
|
+
if (typeof value === "string") {
|
|
67
|
+
if (value.includes(",")) {
|
|
68
|
+
const values = value.split(",").map((v) => v.trim()).filter(Boolean);
|
|
69
|
+
if (values.length > 0) {
|
|
70
|
+
if (isJsonArray) {
|
|
71
|
+
conditions2.push(
|
|
72
|
+
import_drizzle_orm.sql`
|
|
73
|
+
EXISTS (
|
|
74
|
+
SELECT 1 FROM jsonb_array_elements_text(${targetColumn}) tag
|
|
75
|
+
WHERE tag LIKE ${`%${values[0]}%`}
|
|
76
|
+
)
|
|
77
|
+
`
|
|
78
|
+
);
|
|
79
|
+
} else if (isIdField) {
|
|
80
|
+
conditions2.push((0, import_drizzle_orm.inArray)(targetColumn, values));
|
|
81
|
+
} else {
|
|
82
|
+
conditions2.push(
|
|
83
|
+
(0, import_drizzle_orm.or)(
|
|
84
|
+
...values.map((v) => (0, import_drizzle_orm.ilike)(targetColumn, `%${v}%`))
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
if (isJsonArray) {
|
|
91
|
+
conditions2.push(
|
|
92
|
+
import_drizzle_orm.sql`
|
|
93
|
+
EXISTS (
|
|
94
|
+
SELECT 1 FROM jsonb_array_elements_text(${targetColumn}) tag
|
|
95
|
+
WHERE tag LIKE ${`%${value}%`}
|
|
96
|
+
)
|
|
97
|
+
`
|
|
98
|
+
);
|
|
99
|
+
} else if (isIdField) {
|
|
100
|
+
conditions2.push((0, import_drizzle_orm.eq)(targetColumn, value));
|
|
101
|
+
} else {
|
|
102
|
+
conditions2.push((0, import_drizzle_orm.ilike)(targetColumn, `%${value}%`));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
conditions2.push((0, import_drizzle_orm.eq)(targetColumn, value));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function buildConditions(filters2, table2, relations2) {
|
|
110
|
+
const conditions2 = [];
|
|
111
|
+
for (const [key, value] of Object.entries(filters2)) {
|
|
112
|
+
if (!value)
|
|
113
|
+
continue;
|
|
114
|
+
if (key.endsWith("AtFrom") || key.endsWith("AtTo")) {
|
|
115
|
+
const baseFieldName = key.replace(/(AtFrom|AtTo)$/, "");
|
|
116
|
+
const targetColumn2 = findTargetColumn(
|
|
117
|
+
`${baseFieldName}At`,
|
|
118
|
+
table2,
|
|
119
|
+
relations2
|
|
120
|
+
);
|
|
121
|
+
if (!targetColumn2)
|
|
122
|
+
continue;
|
|
123
|
+
if (key.endsWith("AtFrom")) {
|
|
124
|
+
conditions2.push((0, import_drizzle_orm.gte)(targetColumn2, new Date(value)));
|
|
125
|
+
} else if (key.endsWith("AtTo")) {
|
|
126
|
+
conditions2.push((0, import_drizzle_orm.lte)(targetColumn2, new Date(value)));
|
|
127
|
+
}
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const targetColumn = findTargetColumn(
|
|
131
|
+
key,
|
|
132
|
+
table2,
|
|
133
|
+
relations2
|
|
134
|
+
);
|
|
135
|
+
if (!targetColumn)
|
|
136
|
+
continue;
|
|
137
|
+
addCondition(conditions2, key, value, targetColumn);
|
|
138
|
+
}
|
|
139
|
+
return conditions2;
|
|
140
|
+
}
|
|
141
|
+
function buildOrderBy(table2, orderBy2, orderDir2) {
|
|
142
|
+
const orderColumn = table2[orderBy2];
|
|
143
|
+
return orderDir2 === "asc" ? (0, import_drizzle_orm.asc)(orderColumn) : (0, import_drizzle_orm.desc)(orderColumn);
|
|
144
|
+
}
|
|
145
|
+
const baseQuery = buildBaseQuery(table, fields, relations);
|
|
146
|
+
const conditions = buildConditions(filters, table, relations);
|
|
147
|
+
const query = baseQuery.where(conditions.length > 0 ? (0, import_drizzle_orm.and)(...conditions) : void 0).orderBy(buildOrderBy(table, orderBy, orderDir)).limit(pageSize).offset((page - 1) * pageSize);
|
|
148
|
+
const countQuery = db.select({ count: import_drizzle_orm.sql`COUNT(DISTINCT ${table.id})` }).from(table).where(conditions.length > 0 ? (0, import_drizzle_orm.and)(...conditions) : void 0);
|
|
149
|
+
if (relations == null ? void 0 : relations.length) {
|
|
150
|
+
for (const { table: relationTable, sql: joinSql } of relations) {
|
|
151
|
+
if (relationTable) {
|
|
152
|
+
query.leftJoin(relationTable, joinSql);
|
|
153
|
+
countQuery.leftJoin(relationTable, joinSql);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return { countQuery, query };
|
|
158
|
+
}
|
|
159
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
160
|
+
0 && (module.exports = {
|
|
161
|
+
getListQuery
|
|
162
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ZodSchema } from "zod";
|
|
2
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
+
import { BaseTable, GetListRelations } from "../types";
|
|
4
|
+
export declare function getActionFn<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, querySchema, relations, table, }: {
|
|
5
|
+
bodySchema: T;
|
|
6
|
+
db: NodePgDatabase<any>;
|
|
7
|
+
jsonArrayFields?: string[];
|
|
8
|
+
querySchema: Q;
|
|
9
|
+
relations?: GetListRelations;
|
|
10
|
+
table: TTable;
|
|
11
|
+
}): any;
|
|
12
|
+
//# sourceMappingURL=get-action-fn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-action-fn.d.ts","sourceRoot":"","sources":["get-action-fn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAGhC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAwB;AAE9D,wBAAgB,WAAW,CACzB,CAAC,SAAS,SAAS,EACnB,CAAC,SAAS,SAAS,EACnB,MAAM,SAAS,SAAS,EACxB,EACA,UAAU,EACV,EAAE,EACF,eAAe,EACf,WAAW,EACX,SAAS,EACT,KAAK,GACN,EAAE;IACD,UAAU,EAAE,CAAC,CAAC;IACd,EAAE,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC;IACf,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,OA8CA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/backend/actions/get-action-fn.ts
|
|
20
|
+
var get_action_fn_exports = {};
|
|
21
|
+
__export(get_action_fn_exports, {
|
|
22
|
+
getActionFn: () => getActionFn
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(get_action_fn_exports);
|
|
25
|
+
var import_next_rest_framework = require("next-rest-framework");
|
|
26
|
+
var import_get_List_query = require("./get-List-query");
|
|
27
|
+
var import_get_list_data = require("./get-list-data");
|
|
28
|
+
function getActionFn({
|
|
29
|
+
bodySchema,
|
|
30
|
+
db,
|
|
31
|
+
jsonArrayFields,
|
|
32
|
+
querySchema,
|
|
33
|
+
relations,
|
|
34
|
+
table
|
|
35
|
+
}) {
|
|
36
|
+
return (0, import_next_rest_framework.rpcOperation)().input({
|
|
37
|
+
body: querySchema,
|
|
38
|
+
contentType: "application/json"
|
|
39
|
+
}).outputs([
|
|
40
|
+
{
|
|
41
|
+
body: bodySchema,
|
|
42
|
+
contentType: "application/json"
|
|
43
|
+
}
|
|
44
|
+
]).handler(async (params) => {
|
|
45
|
+
const fields = {};
|
|
46
|
+
for (const key of Object.keys(bodySchema.shape)) {
|
|
47
|
+
const field = table[key];
|
|
48
|
+
if (field) {
|
|
49
|
+
fields[key] = field;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const { query, countQuery } = (0, import_get_List_query.getListQuery)({
|
|
53
|
+
db,
|
|
54
|
+
fields,
|
|
55
|
+
jsonArrayFields,
|
|
56
|
+
params,
|
|
57
|
+
relations,
|
|
58
|
+
table
|
|
59
|
+
});
|
|
60
|
+
const {
|
|
61
|
+
data: [result]
|
|
62
|
+
} = await (0, import_get_list_data.getListData)({
|
|
63
|
+
bodySchema,
|
|
64
|
+
countQuery,
|
|
65
|
+
current: 1,
|
|
66
|
+
pageSize: 1,
|
|
67
|
+
query
|
|
68
|
+
})();
|
|
69
|
+
return result || {};
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
getActionFn
|
|
75
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ZodSchema } from "zod";
|
|
2
|
+
import { BaseTable, GetListRelations } from "../types";
|
|
3
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
4
|
+
export declare function getListActionFn<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, querySchema, relations, table, }: {
|
|
5
|
+
bodySchema: T;
|
|
6
|
+
db: NodePgDatabase<any>;
|
|
7
|
+
jsonArrayFields?: string[];
|
|
8
|
+
querySchema: Q;
|
|
9
|
+
relations?: GetListRelations;
|
|
10
|
+
table: TTable;
|
|
11
|
+
}): any;
|
|
12
|
+
//# sourceMappingURL=get-list-action-fn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-list-action-fn.d.ts","sourceRoot":"","sources":["get-list-action-fn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAwB;AAM9D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,wBAAgB,eAAe,CAC7B,CAAC,SAAS,SAAS,EACnB,CAAC,SAAS,SAAS,EACnB,MAAM,SAAS,SAAS,EACxB,EACA,UAAU,EACV,EAAE,EACF,eAAe,EACf,WAAW,EACX,SAAS,EACT,KAAK,GACN,EAAE;IACD,UAAU,EAAE,CAAC,CAAC;IACd,EAAE,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC;IACf,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,OA2CA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/backend/actions/get-list-action-fn.ts
|
|
20
|
+
var get_list_action_fn_exports = {};
|
|
21
|
+
__export(get_list_action_fn_exports, {
|
|
22
|
+
getListActionFn: () => getListActionFn
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(get_list_action_fn_exports);
|
|
25
|
+
var import_next_rest_framework = require("next-rest-framework");
|
|
26
|
+
var import_schemas = require("../schemas");
|
|
27
|
+
var import_get_List_query = require("./get-List-query");
|
|
28
|
+
var import_get_list_data = require("./get-list-data");
|
|
29
|
+
function getListActionFn({
|
|
30
|
+
bodySchema,
|
|
31
|
+
db,
|
|
32
|
+
jsonArrayFields,
|
|
33
|
+
querySchema,
|
|
34
|
+
relations,
|
|
35
|
+
table
|
|
36
|
+
}) {
|
|
37
|
+
return (0, import_next_rest_framework.rpcOperation)().input({
|
|
38
|
+
body: querySchema,
|
|
39
|
+
contentType: "application/json"
|
|
40
|
+
}).outputs([
|
|
41
|
+
{
|
|
42
|
+
body: (0, import_schemas.listBodySchema)(bodySchema),
|
|
43
|
+
contentType: "application/json"
|
|
44
|
+
}
|
|
45
|
+
]).handler(async (params) => {
|
|
46
|
+
const { current, pageSize, ...other } = params;
|
|
47
|
+
const fields = {};
|
|
48
|
+
for (const key of Object.keys(bodySchema.shape)) {
|
|
49
|
+
const field = table[key];
|
|
50
|
+
if (field) {
|
|
51
|
+
fields[key] = field;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const { query, countQuery } = (0, import_get_List_query.getListQuery)({
|
|
55
|
+
db,
|
|
56
|
+
fields,
|
|
57
|
+
jsonArrayFields,
|
|
58
|
+
params: other,
|
|
59
|
+
relations,
|
|
60
|
+
table
|
|
61
|
+
});
|
|
62
|
+
return (0, import_get_list_data.getListData)({
|
|
63
|
+
bodySchema,
|
|
64
|
+
countQuery,
|
|
65
|
+
current,
|
|
66
|
+
pageSize,
|
|
67
|
+
query
|
|
68
|
+
})();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
getListActionFn
|
|
74
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ZodSchema } from "zod";
|
|
2
|
+
import { getListQuery } from "./get-List-query";
|
|
3
|
+
export declare function getListData<B extends ZodSchema>({ query, countQuery, pageSize, current, bodySchema, }: {
|
|
4
|
+
bodySchema: B;
|
|
5
|
+
current?: number;
|
|
6
|
+
pageSize?: number;
|
|
7
|
+
} & ReturnType<typeof getListQuery>): any;
|
|
8
|
+
//# sourceMappingURL=get-list-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-list-data.d.ts","sourceRoot":"","sources":["get-list-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,EAC/C,KAAK,EACL,UAAU,EACV,QAAa,EACb,OAAW,EACX,UAAU,GACX,EAAE;IACD,UAAU,EAAE,CAAC,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,OAoBlC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/backend/actions/get-list-data.ts
|
|
20
|
+
var get_list_data_exports = {};
|
|
21
|
+
__export(get_list_data_exports, {
|
|
22
|
+
getListData: () => getListData
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(get_list_data_exports);
|
|
25
|
+
var import_next_rest_framework = require("next-rest-framework");
|
|
26
|
+
var import_schemas = require("../schemas");
|
|
27
|
+
function getListData({
|
|
28
|
+
query,
|
|
29
|
+
countQuery,
|
|
30
|
+
pageSize = 10,
|
|
31
|
+
current = 1,
|
|
32
|
+
bodySchema
|
|
33
|
+
}) {
|
|
34
|
+
return (0, import_next_rest_framework.rpcOperation)().outputs([
|
|
35
|
+
{
|
|
36
|
+
body: (0, import_schemas.listBodySchema)(bodySchema),
|
|
37
|
+
contentType: "application/json"
|
|
38
|
+
}
|
|
39
|
+
]).handler(async () => {
|
|
40
|
+
const data = await query.limit(+pageSize).offset((+current - 1) * +pageSize).execute();
|
|
41
|
+
const [{ count }] = await countQuery.execute();
|
|
42
|
+
return { data, total: Number(count) };
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
getListData
|
|
48
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { deleteActionFn } from "./delete-action-fn";
|
|
2
|
+
export { getActionFn } from "./get-action-fn";
|
|
3
|
+
export { getListActionFn } from "./get-list-action-fn";
|
|
4
|
+
export { postActionFn } from "./post-action-fn";
|
|
5
|
+
export { putActionFn } from "./put-action-fn";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|