@kaspernj/api-maker 1.0.203 → 1.0.206
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/{.eslintrc.js → .eslintrc.cjs} +0 -0
- package/__tests__/base-model.test.js +11 -9
- package/__tests__/cable-connection-pool.test.js +5 -3
- package/__tests__/cable-subscription-pool.test.js +1 -1
- package/__tests__/can-can.test.js +4 -3
- package/__tests__/collection.test.js +1 -1
- package/__tests__/custom-error.test.js +1 -1
- package/__tests__/merge.test.js +1 -1
- package/__tests__/model-name.test.js +3 -2
- package/__tests__/model-prop-type.test.js +3 -3
- package/__tests__/params.test.js +1 -1
- package/__tests__/routes-native.test.js +4 -4
- package/__tests__/routes.test.js +1 -1
- package/__tests__/serializer.test.js +2 -2
- package/__tests__/support/task.js +1 -1
- package/__tests__/support/user.js +2 -2
- package/jest.config.js +3 -2
- package/package.json +3 -2
- package/src/{api.js → api.mjs} +2 -2
- package/src/attribute-not-loaded-error.mjs +1 -0
- package/src/{base-error.cjs → base-error.mjs} +3 -3
- package/src/{base-model.cjs → base-model.mjs} +31 -35
- package/src/{cable-connection-pool.cjs → cable-connection-pool.mjs} +8 -7
- package/src/{cable-subscription-pool.cjs → cable-subscription-pool.mjs} +8 -8
- package/src/{cable-subscription.cjs → cable-subscription.mjs} +3 -3
- package/src/can-can-loader.jsx +4 -4
- package/src/{can-can.cjs → can-can.mjs} +10 -10
- package/src/channels-consumer.mjs +3 -0
- package/src/collection-loader.jsx +10 -10
- package/src/{collection.cjs → collection.mjs} +8 -8
- package/src/{command-submit-data.cjs → command-submit-data.mjs} +3 -3
- package/src/{commands-pool.cjs → commands-pool.mjs} +16 -16
- package/src/{config.js → config.mjs} +3 -2
- package/src/{custom-error.cjs → custom-error.mjs} +2 -2
- package/src/{deserializer.cjs → deserializer.mjs} +6 -6
- package/src/{destroy-error.cjs → destroy-error.mjs} +2 -2
- package/src/devise.mjs +4 -4
- package/src/{error-logger.cjs → error-logger.mjs} +5 -5
- package/src/{error-messages.cjs → error-messages.mjs} +2 -2
- package/src/event-connection.jsx +4 -4
- package/src/event-created.jsx +5 -5
- package/src/event-destroyed.jsx +4 -4
- package/src/event-emitter-listener.jsx +3 -3
- package/src/event-listener.jsx +3 -3
- package/src/event-model-class.jsx +4 -4
- package/src/event-updated.jsx +5 -5
- package/src/{instance-of-class-name.cjs → instance-of-class-name.mjs} +2 -2
- package/src/{key-value-store.cjs → key-value-store.mjs} +6 -5
- package/src/{logger.cjs → logger.mjs} +7 -5
- package/src/{merge.cjs → merge.mjs} +1 -1
- package/src/model-class-require.mjs +10 -0
- package/src/{model-events.cjs → model-events.mjs} +3 -3
- package/src/model-load-wrapper.jsx +9 -4
- package/src/{model-name.cjs → model-name.mjs} +7 -5
- package/src/{model-prop-type.cjs → model-prop-type.mjs} +3 -3
- package/src/model-recipes-model-loader.mjs +2 -2
- package/src/{models-response-reader.cjs → models-response-reader.mjs} +5 -5
- package/src/models.mjs.erb +16 -0
- package/src/{money-formatter.cjs → money-formatter.mjs} +4 -4
- package/src/not-loaded-error.mjs +1 -0
- package/src/{params.cjs → params.mjs} +5 -5
- package/src/{preloaded.cjs → preloaded.mjs} +3 -3
- package/src/{result.cjs → result.mjs} +1 -1
- package/src/{routes-native.cjs → routes-native.mjs} +8 -8
- package/src/{routes.cjs → routes.mjs} +3 -3
- package/src/{serializer.cjs → serializer.mjs} +2 -2
- package/src/{services.cjs → services.mjs} +6 -6
- package/src/{source-maps-loader.cjs → source-maps-loader.mjs} +4 -4
- package/src/updated-attribute.jsx +5 -5
- package/src/{validation-error.cjs → validation-error.mjs} +3 -3
- package/src/{validation-errors.cjs → validation-errors.mjs} +4 -4
- package/src/with-router.jsx +1 -1
- package/src/attribute-not-loaded-error.cjs +0 -1
- package/src/channels-consumer.cjs +0 -3
- package/src/model-class-require.cjs +0 -9
- package/src/model-recipes.mjs.erb +0 -3
- package/src/models.cjs +0 -7
- package/src/not-loaded-error.cjs +0 -1
|
File without changes
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
import BaseModel from "../src/base-model.mjs"
|
|
2
|
+
import CustomError from "../src/custom-error.mjs"
|
|
3
|
+
import {jest} from "@jest/globals"
|
|
4
|
+
import {JSDOM} from "jsdom"
|
|
5
|
+
import ValidationError from "../src/validation-error.mjs"
|
|
6
|
+
import User from "./support/user.mjs"
|
|
7
|
+
|
|
1
8
|
jest.mock("@rails/actioncable", () => ({
|
|
2
9
|
createConsumer: () => ({})
|
|
3
10
|
}))
|
|
4
11
|
|
|
5
|
-
const BaseModel = require("../src/base-model.cjs")
|
|
6
|
-
const CustomError = require("../src/custom-error.cjs")
|
|
7
|
-
const {JSDOM} = require("jsdom")
|
|
8
12
|
const {window} = new JSDOM()
|
|
9
13
|
const document = window.document
|
|
10
|
-
const ValidationError = require("../src/validation-error.cjs")
|
|
11
|
-
const User = require("./support/user")
|
|
12
14
|
|
|
13
15
|
describe("BaseModel", () => {
|
|
14
16
|
describe("identifierKey", () => {
|
|
@@ -48,20 +50,20 @@ describe("BaseModel", () => {
|
|
|
48
50
|
const form = document.createElement("form")
|
|
49
51
|
const model = new BaseModel()
|
|
50
52
|
const dispatchEventSpy = jest.spyOn(form, "dispatchEvent").mockImplementation(() => "asd")
|
|
51
|
-
const newCustomEventSpy = jest.spyOn(
|
|
53
|
+
const newCustomEventSpy = jest.spyOn(BaseModel, "newCustomEvent").mockImplementation(() => "asd")
|
|
52
54
|
|
|
53
55
|
it("throws the validation errors if no options are given", () => {
|
|
54
|
-
expect(() =>
|
|
56
|
+
expect(() => BaseModel.parseValidationErrors({error, model})).toThrow(ValidationError)
|
|
55
57
|
})
|
|
56
58
|
|
|
57
59
|
it("throws the validation errors and dispatches an event to the form", () => {
|
|
58
|
-
expect(() =>
|
|
60
|
+
expect(() => BaseModel.parseValidationErrors({error, model, options: {form}})).toThrow(ValidationError)
|
|
59
61
|
expect(dispatchEventSpy).toHaveBeenCalled()
|
|
60
62
|
expect(newCustomEventSpy).toHaveBeenCalled()
|
|
61
63
|
})
|
|
62
64
|
|
|
63
65
|
it("doesnt throw validation errors if disabled", () => {
|
|
64
|
-
|
|
66
|
+
BaseModel.parseValidationErrors({error, model, options: {throwValidationError: false}})
|
|
65
67
|
expect(dispatchEventSpy).toHaveBeenCalled()
|
|
66
68
|
expect(newCustomEventSpy).toHaveBeenCalled()
|
|
67
69
|
})
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import CableConnectionPool from "../src/cable-connection-pool.mjs"
|
|
2
|
+
import CableSubscriptionPool from "../src/cable-subscription-pool.mjs"
|
|
3
|
+
import {digg} from "diggerize"
|
|
4
|
+
import {jest} from "@jest/globals"
|
|
5
|
+
|
|
1
6
|
jest.mock("@rails/actioncable", () => ({
|
|
2
7
|
createConsumer: () => ({})
|
|
3
8
|
}))
|
|
4
|
-
const CableConnectionPool = require("../src/cable-connection-pool.cjs")
|
|
5
|
-
const CableSubscriptionPool = require("../src/cable-subscription-pool.cjs")
|
|
6
|
-
const {digg} = require("diggerize")
|
|
7
9
|
|
|
8
10
|
describe("CableConnectionPool", () => {
|
|
9
11
|
describe("connectCreated", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
jest.mock("@rails/actioncable", () => ({
|
|
2
2
|
createConsumer: () => ({})
|
|
3
3
|
}))
|
|
4
|
-
|
|
4
|
+
import CableSubscriptionPool from "../src/cable-subscription-pool.mjs"
|
|
5
5
|
|
|
6
6
|
describe("CableSubscriptionPool", () => {
|
|
7
7
|
describe("onUnsubscribe", () => {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import CanCan from "../src/can-can.mjs"
|
|
2
|
+
import {jest} from "@jest/globals"
|
|
2
3
|
|
|
3
|
-
jest.mock("../src/services.
|
|
4
|
+
jest.mock("../src/services.mjs")
|
|
4
5
|
|
|
5
6
|
describe("CanCan", () => {
|
|
6
7
|
const canCan = CanCan.current()
|
|
7
8
|
|
|
8
9
|
describe("resetAbilities", () => {
|
|
9
10
|
test("that reset abilities and load abilities not have concurrency issues", async () => {
|
|
10
|
-
|
|
11
|
+
import Services from "../src/services.mjs"
|
|
11
12
|
const mockedCurrent = jest.fn().mockReturnValue({
|
|
12
13
|
sendRequest: async () => ({abilities: ["loaded"]})
|
|
13
14
|
})
|
package/__tests__/merge.test.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import I18nOnSteroids from "i18n-on-steroids"
|
|
2
|
+
import ModelName from "../src/model-name.mjs"
|
|
3
|
+
|
|
2
4
|
const i18n = new I18nOnSteroids()
|
|
3
|
-
const ModelName = require("../src/model-name.cjs")
|
|
4
5
|
|
|
5
6
|
const initializeI18n = () => {
|
|
6
7
|
i18n.scanObject({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import ModelPropType from "../src/model-prop-type.mjs"
|
|
2
|
+
import Task from "./support/task.mjs"
|
|
3
|
+
import User from "./support/user.mjs"
|
|
4
4
|
|
|
5
5
|
describe("ModelPropType", () => {
|
|
6
6
|
describe("ofModel", () => {
|
package/__tests__/params.test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import RoutesNative from "../src/routes-native.mjs"
|
|
2
2
|
const testRoutes = () => ({
|
|
3
3
|
routes: [
|
|
4
4
|
{"name": "blank", "path": "/blank", "component": "blank"},
|
|
@@ -76,10 +76,10 @@ describe("RoutesNative", () => {
|
|
|
76
76
|
})
|
|
77
77
|
|
|
78
78
|
it("generates urls", () => {
|
|
79
|
-
if (!
|
|
79
|
+
if (!globalThis.location) globalThis.location = {} // eslint-disable-line jest/no-if
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
globalThis.location.host = "localhost"
|
|
82
|
+
globalThis.location.protocol = "http:"
|
|
83
83
|
|
|
84
84
|
const test = routesNative({args: {localized: true}, currentLocale: "en"})
|
|
85
85
|
const daRoute = test.editDrinkUrl(5, {drink: {name: "Pina Colada"}, locale: "da"})
|
package/__tests__/routes.test.js
CHANGED
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
"name": "@kaspernj/api-maker",
|
|
19
|
-
"version": "1.0.
|
|
19
|
+
"version": "1.0.206",
|
|
20
|
+
"type": "module",
|
|
20
21
|
"description": "",
|
|
21
22
|
"main": "index.js",
|
|
22
23
|
"repository": {
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
},
|
|
31
32
|
"homepage": "https://github.com/kaspernj/api_maker",
|
|
32
33
|
"scripts": {
|
|
33
|
-
"eslint": "eslint --ext .
|
|
34
|
+
"eslint": "eslint --ext .mjs,.js,.jsx",
|
|
34
35
|
"eslint-find-rules": "eslint-find-rules",
|
|
35
36
|
"test": "jest"
|
|
36
37
|
},
|
package/src/{api.js → api.mjs}
RENAMED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class AttributeNotLoadedError extends Error {}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {dig, digg} from "diggerize"
|
|
2
|
+
import errorMessages from "./error-messages.mjs"
|
|
3
3
|
|
|
4
4
|
class BaseError extends Error {
|
|
5
5
|
constructor (message, args = {}) {
|
|
@@ -37,4 +37,4 @@ class BaseError extends Error {
|
|
|
37
37
|
|
|
38
38
|
BaseError.apiMakerType = "BaseError"
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
export default BaseError
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const shared = {}
|
|
16
|
-
|
|
17
|
-
const newCustomEvent = (validationErrors) => {
|
|
18
|
-
return new CustomEvent("validation-errors", {detail: validationErrors})
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const sendValidationErrorsEvent = (validationErrors, options) => {
|
|
22
|
-
if (options && options.form) {
|
|
23
|
-
const event = newCustomEvent(validationErrors)
|
|
24
|
-
options.form.dispatchEvent(event)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
1
|
+
import AttributeNotLoadedError from "./attribute-not-loaded-error.mjs"
|
|
2
|
+
import Collection from "./collection.mjs"
|
|
3
|
+
import CommandsPool from "./commands-pool.mjs"
|
|
4
|
+
import Config from "@kaspernj/api-maker/src/config.mjs"
|
|
5
|
+
import CustomError from "./custom-error.mjs"
|
|
6
|
+
import {digg} from "diggerize"
|
|
7
|
+
import FormDataObjectizer from "form-data-objectizer"
|
|
8
|
+
import inflection from "inflection"
|
|
9
|
+
import ModelName from "./model-name.mjs"
|
|
10
|
+
import NotLoadedError from "./not-loaded-error.mjs"
|
|
11
|
+
import objectToFormData from "object-to-formdata"
|
|
12
|
+
import Services from "./services.mjs"
|
|
13
|
+
import ValidationError from "./validation-error.mjs"
|
|
14
|
+
import {ValidationErrors} from "./validation-errors.mjs"
|
|
27
15
|
|
|
28
16
|
class BaseModel {
|
|
29
17
|
static modelClassData () {
|
|
30
18
|
throw new Error("modelClassData should be overriden by child")
|
|
31
19
|
}
|
|
32
20
|
|
|
21
|
+
static newCustomEvent = (validationErrors) => {
|
|
22
|
+
return new CustomEvent("validation-errors", {detail: validationErrors})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static sendValidationErrorsEvent = (validationErrors, options) => {
|
|
26
|
+
if (options && options.form) {
|
|
27
|
+
const event = BaseModel.newCustomEvent(validationErrors)
|
|
28
|
+
options.form.dispatchEvent(event)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
33
32
|
static async find (id) {
|
|
34
33
|
const primaryKeyName = this.modelClassData().primaryKey
|
|
35
34
|
const query = {}
|
|
@@ -56,17 +55,13 @@ class BaseModel {
|
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
static modelName () {
|
|
59
|
-
return new ModelName({
|
|
58
|
+
return new ModelName({modelClassData: this.modelClassData()})
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
static ransack (query = {}) {
|
|
63
62
|
return new Collection({modelClass: this}, {ransack: query})
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
static setI18n (i18n) {
|
|
67
|
-
shared.i18n = i18n
|
|
68
|
-
}
|
|
69
|
-
|
|
70
65
|
constructor (args = {}) {
|
|
71
66
|
this.changes = {}
|
|
72
67
|
this.newRecord = args.isNewRecord
|
|
@@ -319,7 +314,7 @@ class BaseModel {
|
|
|
319
314
|
validationErrors: digg(error, "args", "response", "validation_errors")
|
|
320
315
|
})
|
|
321
316
|
|
|
322
|
-
sendValidationErrorsEvent(validationErrors, options)
|
|
317
|
+
BaseModel.sendValidationErrorsEvent(validationErrors, options)
|
|
323
318
|
|
|
324
319
|
if (!options || options.throwValidationError != false) {
|
|
325
320
|
throw new ValidationError(validationErrors, digg(error, "args"))
|
|
@@ -328,8 +323,9 @@ class BaseModel {
|
|
|
328
323
|
|
|
329
324
|
static humanAttributeName (attributeName) {
|
|
330
325
|
const keyName = digg(this.modelClassData(), "i18nKey")
|
|
326
|
+
const i18n = Config.getI18n()
|
|
331
327
|
|
|
332
|
-
if (
|
|
328
|
+
if (i18n) return i18n.t(`activerecord.attributes.${keyName}.${BaseModel.snakeCase(attributeName)}`, {defaultValue: attributeName})
|
|
333
329
|
|
|
334
330
|
return inflection.humanize(attributeName)
|
|
335
331
|
}
|
|
@@ -660,7 +656,7 @@ class BaseModel {
|
|
|
660
656
|
if (args instanceof FormData) {
|
|
661
657
|
postData = args
|
|
662
658
|
} else {
|
|
663
|
-
postData = objectToFormData(args, {}, null, "args")
|
|
659
|
+
postData = objectToFormData.serialize(args, {}, null, "args")
|
|
664
660
|
}
|
|
665
661
|
} else {
|
|
666
662
|
postData = new FormData()
|
|
@@ -844,4 +840,4 @@ class BaseModel {
|
|
|
844
840
|
|
|
845
841
|
BaseModel.apiMakerType = "BaseModel"
|
|
846
842
|
|
|
847
|
-
|
|
843
|
+
export default BaseModel
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import CableSubscriptionPool from "./cable-subscription-pool.mjs"
|
|
2
|
+
import CableSubscription from "./cable-subscription.mjs"
|
|
3
|
+
import {dig} from "diggerize"
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const shared = {}
|
|
6
|
+
|
|
7
|
+
export default class ApiMakerCableConnectionPool {
|
|
6
8
|
static current () {
|
|
7
|
-
if (!
|
|
8
|
-
global.apiMakerCableConnectionPool = new ApiMakerCableConnectionPool()
|
|
9
|
+
if (!shared.apiMakerCableConnectionPool) shared.apiMakerCableConnectionPool = new ApiMakerCableConnectionPool()
|
|
9
10
|
|
|
10
|
-
return
|
|
11
|
+
return shared.apiMakerCableConnectionPool
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
constructor () {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import ChannelsConsumer from "./channels-consumer.mjs"
|
|
2
|
+
import CommandsPool from "./commands-pool.mjs"
|
|
3
|
+
import Deserializer from "./deserializer.mjs"
|
|
4
|
+
import {digg} from "diggerize"
|
|
5
|
+
import inflection from "inflection"
|
|
6
|
+
import Logger from "./logger.mjs"
|
|
7
|
+
|
|
8
|
+
export default class ApiMakerCableSubscriptionPool {
|
|
9
9
|
constructor () {
|
|
10
10
|
this.activeSubscriptions = 0
|
|
11
11
|
this.connected = false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import EventEmitter from "events"
|
|
2
|
+
import Logger from "./logger.mjs"
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default class ApiMakerCableSubscription {
|
|
5
5
|
constructor () {
|
|
6
6
|
this.events = new EventEmitter()
|
|
7
7
|
this.subscribed = true
|
package/src/can-can-loader.jsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import ApiMakerEventEmitterListener from "./event-emitter-listener"
|
|
2
2
|
import {digg, digs} from "diggerize"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import CanCan from "./can-can.mjs"
|
|
4
|
+
import PropTypes from "prop-types"
|
|
5
|
+
import propTypesExact from "prop-types-exact"
|
|
6
|
+
import React from "react"
|
|
7
7
|
|
|
8
8
|
export default class ApiMakerCanCanLoader extends React.PureComponent {
|
|
9
9
|
static propTypes = propTypesExact({
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {digg} from "diggerize"
|
|
2
|
+
import EventEmitter from "events"
|
|
3
|
+
import inflection from "inflection"
|
|
4
|
+
import {ReadersWriterLock} from "epic-locks"
|
|
5
|
+
import Services from "./services.mjs"
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const shared = {}
|
|
8
|
+
|
|
9
|
+
export default class ApiMakerCanCan {
|
|
8
10
|
static current () {
|
|
9
|
-
if (!
|
|
10
|
-
global.currentApiMakerCanCan = new ApiMakerCanCan()
|
|
11
|
-
}
|
|
11
|
+
if (!shared.currentApiMakerCanCan) shared.currentApiMakerCanCan = new ApiMakerCanCan()
|
|
12
12
|
|
|
13
|
-
return
|
|
13
|
+
return shared.currentApiMakerCanCan
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
constructor () {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import Collection from "@kaspernj/api-maker/src/collection"
|
|
2
|
+
import {debounce} from "debounce"
|
|
3
|
+
import {digg, digs} from "diggerize"
|
|
4
|
+
import EventCreated from "@kaspernj/api-maker/src/event-created"
|
|
5
|
+
import EventDestroyed from "@kaspernj/api-maker/src/event-destroyed"
|
|
6
|
+
import EventUpdated from "@kaspernj/api-maker/src/event-updated"
|
|
7
|
+
import instanceOfClassName from "@kaspernj/api-maker/src/instance-of-class-name"
|
|
8
|
+
import Params from "@kaspernj/api-maker/src/params"
|
|
9
|
+
import PropTypes from "prop-types"
|
|
10
|
+
import React from "react"
|
|
11
11
|
|
|
12
12
|
import {LocationChanged} from "on-location-changed/src/location-changed-component"
|
|
13
13
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import cloneDeep from "clone-deep"
|
|
2
|
+
import CommandsPool from "./commands-pool.mjs"
|
|
3
|
+
import {digg} from "diggerize"
|
|
4
|
+
import inflection from "inflection"
|
|
5
|
+
import {merge} from "./merge.mjs"
|
|
6
|
+
import modelClassRequire from "./model-class-require.mjs"
|
|
7
|
+
import Result from "./result.mjs"
|
|
8
8
|
|
|
9
9
|
class ApiMakerCollection {
|
|
10
10
|
constructor (args, queryArgs = {}) {
|
|
@@ -252,4 +252,4 @@ class ApiMakerCollection {
|
|
|
252
252
|
|
|
253
253
|
ApiMakerCollection.apiMakerType = "Collection"
|
|
254
254
|
|
|
255
|
-
|
|
255
|
+
export default ApiMakerCollection
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import objectToFormData from "object-to-formdata"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default class ApiMakerCommandSubmitData {
|
|
4
4
|
constructor (data) {
|
|
5
5
|
this.data = data
|
|
6
6
|
this.filesCount = 0
|
|
@@ -28,7 +28,7 @@ module.exports = class ApiMakerCommandSubmitData {
|
|
|
28
28
|
|
|
29
29
|
objectForFormData.json = JSON.stringify(this.getJsonData())
|
|
30
30
|
|
|
31
|
-
const formData = objectToFormData(objectForFormData)
|
|
31
|
+
const formData = objectToFormData.serialize(objectForFormData)
|
|
32
32
|
|
|
33
33
|
return formData
|
|
34
34
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import Api from "./api.mjs"
|
|
2
|
+
import CommandSubmitData from "./command-submit-data.mjs"
|
|
3
|
+
import CustomError from "./custom-error.mjs"
|
|
4
|
+
import DestroyError from "./destroy-error.mjs"
|
|
5
|
+
import Deserializer from "./deserializer.mjs"
|
|
6
|
+
import {dig, digg} from "diggerize"
|
|
7
|
+
import FormDataObjectizer from "form-data-objectizer"
|
|
8
|
+
import Serializer from "./serializer.mjs"
|
|
9
|
+
import ValidationError from "./validation-error.mjs"
|
|
10
|
+
import {ValidationErrors} from "./validation-errors.mjs"
|
|
11
|
+
|
|
12
|
+
const shared = {}
|
|
13
|
+
|
|
14
|
+
export default class ApiMakerCommandsPool {
|
|
13
15
|
static addCommand (data, args = {}) {
|
|
14
16
|
let pool
|
|
15
17
|
|
|
@@ -31,11 +33,9 @@ module.exports = class ApiMakerCommandsPool {
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
static current () {
|
|
34
|
-
if (!
|
|
35
|
-
global.currentApiMakerCommandsPool = new ApiMakerCommandsPool()
|
|
36
|
-
}
|
|
36
|
+
if (!shared.currentApiMakerCommandsPool) shared.currentApiMakerCommandsPool = new ApiMakerCommandsPool()
|
|
37
37
|
|
|
38
|
-
return
|
|
38
|
+
return shared.currentApiMakerCommandsPool
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
static flush () {
|
|
@@ -15,15 +15,16 @@ const accessors = {
|
|
|
15
15
|
currenciesCollection: {required: true},
|
|
16
16
|
history: {required: false},
|
|
17
17
|
host: {required: false},
|
|
18
|
+
i18n: {required: false},
|
|
18
19
|
routes: {required: false},
|
|
19
20
|
routeDefinitions: {required: false}
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
class ApiMakerConfig {
|
|
23
24
|
constructor() {
|
|
24
|
-
if (!
|
|
25
|
+
if (!globalThis.apiMakerConfigGlobal) globalThis.apiMakerConfigGlobal = {}
|
|
25
26
|
|
|
26
|
-
this.global =
|
|
27
|
+
this.global = globalThis.apiMakerConfigGlobal
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
|