@vsaas/loopback 10.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 (69) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +91 -0
  3. package/common/models/README.md +109 -0
  4. package/common/models/access-token.json +37 -0
  5. package/common/models/acl.json +17 -0
  6. package/common/models/application.json +130 -0
  7. package/common/models/change.json +25 -0
  8. package/common/models/checkpoint.json +14 -0
  9. package/common/models/email.json +11 -0
  10. package/common/models/key-value-model.json +4 -0
  11. package/common/models/role-mapping.json +26 -0
  12. package/common/models/role.json +30 -0
  13. package/common/models/scope.json +14 -0
  14. package/common/models/user.json +118 -0
  15. package/dist/_virtual/_rolldown/runtime.cjs +32 -0
  16. package/dist/common/models/access-token.cjs +144 -0
  17. package/dist/common/models/access-token2.cjs +43 -0
  18. package/dist/common/models/acl.cjs +428 -0
  19. package/dist/common/models/acl2.cjs +27 -0
  20. package/dist/common/models/application.cjs +100 -0
  21. package/dist/common/models/application2.cjs +118 -0
  22. package/dist/common/models/change.cjs +404 -0
  23. package/dist/common/models/change2.cjs +25 -0
  24. package/dist/common/models/checkpoint.cjs +43 -0
  25. package/dist/common/models/checkpoint2.cjs +18 -0
  26. package/dist/common/models/email.cjs +18 -0
  27. package/dist/common/models/email2.cjs +30 -0
  28. package/dist/common/models/key-value-model.cjs +140 -0
  29. package/dist/common/models/key-value-model2.cjs +14 -0
  30. package/dist/common/models/role-mapping.cjs +57 -0
  31. package/dist/common/models/role-mapping2.cjs +34 -0
  32. package/dist/common/models/role.cjs +396 -0
  33. package/dist/common/models/role2.cjs +38 -0
  34. package/dist/common/models/scope.cjs +30 -0
  35. package/dist/common/models/scope2.cjs +21 -0
  36. package/dist/common/models/user.cjs +810 -0
  37. package/dist/common/models/user2.cjs +118 -0
  38. package/dist/index.cjs +16 -0
  39. package/dist/lib/access-context.cjs +228 -0
  40. package/dist/lib/application.cjs +450 -0
  41. package/dist/lib/builtin-models.cjs +60 -0
  42. package/dist/lib/configure-shared-methods.cjs +41 -0
  43. package/dist/lib/connectors/base-connector.cjs +23 -0
  44. package/dist/lib/connectors/mail-direct-transport.cjs +375 -0
  45. package/dist/lib/connectors/mail-stub-transport.cjs +86 -0
  46. package/dist/lib/connectors/mail.cjs +128 -0
  47. package/dist/lib/connectors/memory.cjs +19 -0
  48. package/dist/lib/current-context.cjs +22 -0
  49. package/dist/lib/globalize.cjs +29 -0
  50. package/dist/lib/loopback.cjs +313 -0
  51. package/dist/lib/model.cjs +1009 -0
  52. package/dist/lib/persisted-model.cjs +1835 -0
  53. package/dist/lib/registry.cjs +291 -0
  54. package/dist/lib/runtime.cjs +25 -0
  55. package/dist/lib/server-app.cjs +231 -0
  56. package/dist/lib/utils.cjs +154 -0
  57. package/dist/package.cjs +124 -0
  58. package/dist/server/middleware/context.cjs +7 -0
  59. package/dist/server/middleware/error-handler.cjs +6 -0
  60. package/dist/server/middleware/favicon.cjs +13 -0
  61. package/dist/server/middleware/rest.cjs +44 -0
  62. package/dist/server/middleware/static.cjs +14 -0
  63. package/dist/server/middleware/status.cjs +28 -0
  64. package/dist/server/middleware/token.cjs +66 -0
  65. package/dist/server/middleware/url-not-found.cjs +20 -0
  66. package/favicon.ico +0 -0
  67. package/package.json +121 -0
  68. package/templates/reset-form.ejs +3 -0
  69. package/templates/verify.ejs +9 -0
@@ -0,0 +1,18 @@
1
+ //#region common/models/checkpoint.json
2
+ var require_checkpoint = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
3
+ module.exports = {
4
+ "name": "Checkpoint",
5
+ "properties": {
6
+ "seq": { "type": "number" },
7
+ "time": { "type": "date" },
8
+ "sourceId": { "type": "string" }
9
+ }
10
+ };
11
+ }));
12
+ //#endregion
13
+ Object.defineProperty(exports, "default", {
14
+ enumerable: true,
15
+ get: function() {
16
+ return require_checkpoint();
17
+ }
18
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
3
+ const require_lib_globalize = require("../../lib/globalize.cjs");
4
+ //#region src/common/models/email.ts
5
+ var require_email = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, module) => {
6
+ const g = require_lib_globalize;
7
+ function configureEmail(Email) {
8
+ Email.send = function() {
9
+ throw new Error(g.f("You must connect the {{Email}} Model to a {{Mail}} connector"));
10
+ };
11
+ Email.prototype.send = function() {
12
+ throw new Error(g.f("You must connect the {{Email}} Model to a {{Mail}} connector"));
13
+ };
14
+ }
15
+ module.exports = configureEmail;
16
+ }));
17
+ //#endregion
18
+ module.exports = require_email();
@@ -0,0 +1,30 @@
1
+ //#region common/models/email.json
2
+ var require_email = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
3
+ module.exports = {
4
+ "name": "Email",
5
+ "base": "Model",
6
+ "properties": {
7
+ "to": {
8
+ "type": "String",
9
+ "required": true
10
+ },
11
+ "from": {
12
+ "type": "String",
13
+ "required": true
14
+ },
15
+ "subject": {
16
+ "type": "String",
17
+ "required": true
18
+ },
19
+ "text": { "type": "String" },
20
+ "html": { "type": "String" }
21
+ }
22
+ };
23
+ }));
24
+ //#endregion
25
+ Object.defineProperty(exports, "default", {
26
+ enumerable: true,
27
+ get: function() {
28
+ return require_email();
29
+ }
30
+ });
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
3
+ const require_lib_globalize = require("../../lib/globalize.cjs");
4
+ //#region src/common/models/key-value-model.ts
5
+ var require_key_value_model = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, module) => {
6
+ const g = require_lib_globalize;
7
+ function configureKeyValueModel(KeyValueModel) {
8
+ KeyValueModel.get = function(key, options, callback) {
9
+ throwNotAttached(this.modelName, "get");
10
+ };
11
+ KeyValueModel.set = function(key, value, options, callback) {
12
+ throwNotAttached(this.modelName, "set");
13
+ };
14
+ KeyValueModel.expire = function(key, ttl, options, callback) {
15
+ throwNotAttached(this.modelName, "expire");
16
+ };
17
+ KeyValueModel.ttl = function(key, options, callback) {
18
+ throwNotAttached(this.modelName, "ttl");
19
+ };
20
+ KeyValueModel.keys = function(filter, options, callback) {
21
+ throwNotAttached(this.modelName, "keys");
22
+ };
23
+ KeyValueModel.iterateKeys = function(filter, options) {
24
+ throwNotAttached(this.modelName, "iterateKeys");
25
+ };
26
+ KeyValueModel.setup = function() {
27
+ KeyValueModel.base.setup.apply(this, arguments);
28
+ this.remoteMethod("get", {
29
+ accepts: {
30
+ arg: "key",
31
+ type: "string",
32
+ required: true,
33
+ http: { source: "path" }
34
+ },
35
+ returns: {
36
+ arg: "value",
37
+ type: "any",
38
+ root: true
39
+ },
40
+ http: {
41
+ path: "/:key",
42
+ verb: "get"
43
+ },
44
+ rest: { after: convertNullToNotFoundError }
45
+ });
46
+ this.remoteMethod("set", {
47
+ accepts: [
48
+ {
49
+ arg: "key",
50
+ type: "string",
51
+ required: true,
52
+ http: { source: "path" }
53
+ },
54
+ {
55
+ arg: "value",
56
+ type: "any",
57
+ required: true,
58
+ http: { source: "body" }
59
+ },
60
+ {
61
+ arg: "ttl",
62
+ type: "number",
63
+ http: { source: "query" },
64
+ description: "time to live in milliseconds"
65
+ }
66
+ ],
67
+ http: {
68
+ path: "/:key",
69
+ verb: "put"
70
+ }
71
+ });
72
+ this.remoteMethod("expire", {
73
+ accepts: [{
74
+ arg: "key",
75
+ type: "string",
76
+ required: true,
77
+ http: { source: "path" }
78
+ }, {
79
+ arg: "ttl",
80
+ type: "number",
81
+ required: true,
82
+ http: { source: "form" }
83
+ }],
84
+ http: {
85
+ path: "/:key/expire",
86
+ verb: "put"
87
+ }
88
+ });
89
+ this.remoteMethod("ttl", {
90
+ accepts: {
91
+ arg: "key",
92
+ type: "string",
93
+ required: true,
94
+ http: { source: "path" }
95
+ },
96
+ returns: {
97
+ arg: "value",
98
+ type: "any",
99
+ root: true
100
+ },
101
+ http: {
102
+ path: "/:key/ttl",
103
+ verb: "get"
104
+ }
105
+ });
106
+ this.remoteMethod("keys", {
107
+ accepts: {
108
+ arg: "filter",
109
+ type: "object",
110
+ required: false,
111
+ http: { source: "query" }
112
+ },
113
+ returns: {
114
+ arg: "keys",
115
+ type: ["string"],
116
+ root: true
117
+ },
118
+ http: {
119
+ path: "/keys",
120
+ verb: "get"
121
+ }
122
+ });
123
+ };
124
+ }
125
+ function throwNotAttached(modelName, methodName) {
126
+ throw new Error(g.f("Cannot call %s.%s(). The %s method has not been setup. The {{KeyValueModel}} has not been correctly attached to a {{DataSource}}!", modelName, methodName, methodName));
127
+ }
128
+ function convertNullToNotFoundError(ctx, cb) {
129
+ if (ctx.result !== null) return cb();
130
+ const modelName = ctx.method.sharedClass.name;
131
+ const id = ctx.getArgByName("id");
132
+ const error = new Error(g.f("Unknown \"%s\" {{key}} \"%s\".", modelName, id));
133
+ error.statusCode = error.status = 404;
134
+ error.code = "KEY_NOT_FOUND";
135
+ cb(error);
136
+ }
137
+ module.exports = configureKeyValueModel;
138
+ }));
139
+ //#endregion
140
+ module.exports = require_key_value_model();
@@ -0,0 +1,14 @@
1
+ //#region common/models/key-value-model.json
2
+ var require_key_value_model = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
3
+ module.exports = {
4
+ "name": "KeyValueModel",
5
+ "base": "Model"
6
+ };
7
+ }));
8
+ //#endregion
9
+ Object.defineProperty(exports, "default", {
10
+ enumerable: true,
11
+ get: function() {
12
+ return require_key_value_model();
13
+ }
14
+ });
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
3
+ const require_lib_utils = require("../../lib/utils.cjs");
4
+ //#region src/common/models/role-mapping.ts
5
+ var require_role_mapping = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, module) => {
6
+ const utils = require_lib_utils;
7
+ function configureRoleMapping(RoleMapping) {
8
+ RoleMapping.USER = "USER";
9
+ RoleMapping.APP = RoleMapping.APPLICATION = "APP";
10
+ RoleMapping.ROLE = "ROLE";
11
+ RoleMapping.resolveRelatedModels = function() {
12
+ if (!this.userModel) {
13
+ const reg = this.registry;
14
+ this.roleModel = reg.getModelByType("Role");
15
+ this.userModel = reg.getModelByType("User");
16
+ this.applicationModel = reg.getModelByType("Application");
17
+ }
18
+ };
19
+ RoleMapping.prototype.application = function(callback) {
20
+ callback = callback || utils.createPromiseCallback();
21
+ this.constructor.resolveRelatedModels();
22
+ if (this.principalType === RoleMapping.APPLICATION) this.constructor.applicationModel.findById(this.principalId, callback);
23
+ else process.nextTick(function() {
24
+ callback(null, null);
25
+ });
26
+ return callback.promise;
27
+ };
28
+ RoleMapping.prototype.user = function(callback) {
29
+ callback = callback || utils.createPromiseCallback();
30
+ this.constructor.resolveRelatedModels();
31
+ let userModel;
32
+ if (this.principalType === RoleMapping.USER) {
33
+ userModel = this.constructor.userModel;
34
+ userModel.findById(this.principalId, callback);
35
+ return callback.promise;
36
+ }
37
+ userModel = this.constructor.registry.findModel(this.principalType);
38
+ if (userModel) userModel.findById(this.principalId, callback);
39
+ else process.nextTick(function() {
40
+ callback(null, null);
41
+ });
42
+ return callback.promise;
43
+ };
44
+ RoleMapping.prototype.childRole = function(callback) {
45
+ callback = callback || utils.createPromiseCallback();
46
+ this.constructor.resolveRelatedModels();
47
+ if (this.principalType === RoleMapping.ROLE) this.constructor.roleModel.findById(this.principalId, callback);
48
+ else process.nextTick(function() {
49
+ callback(null, null);
50
+ });
51
+ return callback.promise;
52
+ };
53
+ }
54
+ module.exports = configureRoleMapping;
55
+ }));
56
+ //#endregion
57
+ module.exports = require_role_mapping();
@@ -0,0 +1,34 @@
1
+ //#region common/models/role-mapping.json
2
+ var require_role_mapping = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
3
+ module.exports = {
4
+ "name": "RoleMapping",
5
+ "description": "Map principals to roles",
6
+ "properties": {
7
+ "id": {
8
+ "type": "string",
9
+ "id": true,
10
+ "generated": true
11
+ },
12
+ "principalType": {
13
+ "type": "string",
14
+ "description": "The principal type, such as USER, APPLICATION, ROLE, or user model name in case of multiple user models"
15
+ },
16
+ "principalId": {
17
+ "type": "string",
18
+ "index": true
19
+ }
20
+ },
21
+ "relations": { "role": {
22
+ "type": "belongsTo",
23
+ "model": "Role",
24
+ "foreignKey": "roleId"
25
+ } }
26
+ };
27
+ }));
28
+ //#endregion
29
+ Object.defineProperty(exports, "default", {
30
+ enumerable: true,
31
+ get: function() {
32
+ return require_role_mapping();
33
+ }
34
+ });