@kaspernj/api-maker 1.0.204 → 1.0.207

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 (78) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +0 -0
  2. package/__tests__/base-model.test.js +11 -9
  3. package/__tests__/cable-connection-pool.test.js +5 -3
  4. package/__tests__/cable-subscription-pool.test.js +1 -1
  5. package/__tests__/can-can.test.js +4 -3
  6. package/__tests__/collection.test.js +1 -1
  7. package/__tests__/custom-error.test.js +1 -1
  8. package/__tests__/merge.test.js +1 -1
  9. package/__tests__/model-name.test.js +3 -2
  10. package/__tests__/model-prop-type.test.js +3 -3
  11. package/__tests__/params.test.js +1 -1
  12. package/__tests__/routes-native.test.js +4 -4
  13. package/__tests__/routes.test.js +1 -1
  14. package/__tests__/serializer.test.js +2 -2
  15. package/__tests__/support/task.js +1 -1
  16. package/__tests__/support/user.js +2 -2
  17. package/jest.config.js +3 -2
  18. package/package.json +3 -2
  19. package/src/{api.js → api.mjs} +2 -2
  20. package/src/attribute-not-loaded-error.mjs +1 -0
  21. package/src/{base-error.cjs → base-error.mjs} +3 -3
  22. package/src/{base-model.cjs → base-model.mjs} +28 -28
  23. package/src/{cable-connection-pool.cjs → cable-connection-pool.mjs} +8 -7
  24. package/src/{cable-subscription-pool.cjs → cable-subscription-pool.mjs} +8 -8
  25. package/src/{cable-subscription.cjs → cable-subscription.mjs} +3 -3
  26. package/src/can-can-loader.jsx +4 -4
  27. package/src/{can-can.cjs → can-can.mjs} +10 -10
  28. package/src/channels-consumer.mjs +3 -0
  29. package/src/collection-loader.jsx +10 -10
  30. package/src/{collection.cjs → collection.mjs} +8 -8
  31. package/src/{command-submit-data.cjs → command-submit-data.mjs} +3 -3
  32. package/src/{commands-pool.cjs → commands-pool.mjs} +16 -16
  33. package/src/{config.js → config.mjs} +2 -2
  34. package/src/{custom-error.cjs → custom-error.mjs} +2 -2
  35. package/src/{deserializer.cjs → deserializer.mjs} +6 -6
  36. package/src/{destroy-error.cjs → destroy-error.mjs} +2 -2
  37. package/src/devise.mjs +4 -4
  38. package/src/{error-logger.cjs → error-logger.mjs} +5 -5
  39. package/src/{error-messages.cjs → error-messages.mjs} +2 -2
  40. package/src/event-connection.jsx +4 -4
  41. package/src/event-created.jsx +5 -5
  42. package/src/event-destroyed.jsx +4 -4
  43. package/src/event-emitter-listener.jsx +3 -3
  44. package/src/event-listener.jsx +3 -3
  45. package/src/event-model-class.jsx +4 -4
  46. package/src/event-updated.jsx +5 -5
  47. package/src/{instance-of-class-name.cjs → instance-of-class-name.mjs} +2 -2
  48. package/src/{key-value-store.cjs → key-value-store.mjs} +6 -5
  49. package/src/{logger.cjs → logger.mjs} +7 -5
  50. package/src/{merge.cjs → merge.mjs} +1 -1
  51. package/src/model-class-require.mjs +10 -0
  52. package/src/{model-events.cjs → model-events.mjs} +3 -3
  53. package/src/model-load-wrapper.jsx +9 -4
  54. package/src/{model-name.cjs → model-name.mjs} +5 -5
  55. package/src/{model-prop-type.cjs → model-prop-type.mjs} +3 -3
  56. package/src/model-recipes-model-loader.mjs +2 -2
  57. package/src/{models-response-reader.cjs → models-response-reader.mjs} +5 -5
  58. package/src/models.mjs.erb +16 -0
  59. package/src/{money-formatter.cjs → money-formatter.mjs} +4 -4
  60. package/src/not-loaded-error.mjs +1 -0
  61. package/src/{params.cjs → params.mjs} +5 -5
  62. package/src/{preloaded.cjs → preloaded.mjs} +3 -3
  63. package/src/{result.cjs → result.mjs} +1 -1
  64. package/src/{routes-native.cjs → routes-native.mjs} +8 -8
  65. package/src/{routes.cjs → routes.mjs} +3 -3
  66. package/src/{serializer.cjs → serializer.mjs} +2 -2
  67. package/src/{services.cjs → services.mjs} +6 -6
  68. package/src/{source-maps-loader.cjs → source-maps-loader.mjs} +4 -4
  69. package/src/updated-attribute.jsx +5 -5
  70. package/src/{validation-error.cjs → validation-error.mjs} +3 -3
  71. package/src/{validation-errors.cjs → validation-errors.mjs} +4 -4
  72. package/src/with-router.jsx +1 -1
  73. package/src/attribute-not-loaded-error.cjs +0 -1
  74. package/src/channels-consumer.cjs +0 -3
  75. package/src/model-class-require.cjs +0 -9
  76. package/src/model-recipes.mjs.erb +0 -3
  77. package/src/models.cjs +0 -7
  78. package/src/not-loaded-error.cjs +0 -1
@@ -1,7 +1,7 @@
1
- const {digg} = require("diggerize")
2
- const SourceMapsLoader = require("./source-maps-loader.cjs")
1
+ import {digg} from "diggerize"
2
+ import SourceMapsLoader from "./source-maps-loader.mjs"
3
3
 
4
- module.exports = class ErrorLogger {
4
+ export default class ErrorLogger {
5
5
  constructor () {
6
6
  this.debug = true
7
7
  this.errorOccurred = false
@@ -40,7 +40,7 @@ module.exports = class ErrorLogger {
40
40
  }
41
41
 
42
42
  connectOnError () {
43
- global.addEventListener("error", (event) => {
43
+ globalThis.addEventListener("error", (event) => {
44
44
  this.errorOccurred = true
45
45
 
46
46
  if (!this.isHandlingError) {
@@ -53,7 +53,7 @@ module.exports = class ErrorLogger {
53
53
  }
54
54
 
55
55
  connectUnhandledRejection () {
56
- global.addEventListener("unhandledrejection", (event) => {
56
+ globalThis.addEventListener("unhandledrejection", (event) => {
57
57
  this.errorOccurred = true
58
58
 
59
59
  if (!this.isHandlingError) {
@@ -1,4 +1,4 @@
1
- const {digg} = require("diggerize")
1
+ import {digg} from "diggerize"
2
2
  const errorMessages = (args) => {
3
3
  if (typeof args.response == "object") {
4
4
  return digg(args, "response", "errors").map((error) => {
@@ -11,4 +11,4 @@ const errorMessages = (args) => {
11
11
  }
12
12
  }
13
13
 
14
- module.exports = errorMessages
14
+ export default errorMessages
@@ -1,7 +1,7 @@
1
- const ModelEvents = require("./model-events.cjs")
2
- const PropTypes = require("prop-types")
3
- const propTypesExact = require("prop-types-exact")
4
- const React = require("react")
1
+ import ModelEvents from "./model-events.mjs"
2
+ import PropTypes from "prop-types"
3
+ import propTypesExact from "prop-types-exact"
4
+ import React from "react"
5
5
 
6
6
  export default class ApiMakerEventConnection extends React.PureComponent {
7
7
  static defaultProps = {
@@ -1,8 +1,8 @@
1
- const debounce = require("debounce")
2
- const ModelEvents = require("./model-events.cjs")
3
- const PropTypes = require("prop-types")
4
- const propTypesExact = require("prop-types-exact")
5
- const React = require("react")
1
+ import debounce from "debounce"
2
+ import ModelEvents from "./model-events.mjs"
3
+ import PropTypes from "prop-types"
4
+ import propTypesExact from "prop-types-exact"
5
+ import React from "react"
6
6
 
7
7
  export default class ApiMakerEventCreated extends React.PureComponent {
8
8
  static defaultProps = {
@@ -1,7 +1,7 @@
1
- const ModelEvents = require("./model-events.cjs")
2
- const PropTypes = require("prop-types")
3
- const propTypesExact = require("prop-types-exact")
4
- const React = require("react")
1
+ import ModelEvents from "./model-events.mjs"
2
+ import PropTypes from "prop-types"
3
+ import propTypesExact from "prop-types-exact"
4
+ import React from "react"
5
5
 
6
6
  export default class ApiMakerEventDestroyed extends React.PureComponent {
7
7
  static propTypes = propTypesExact({
@@ -1,6 +1,6 @@
1
- const EventEmitter = require("events")
2
- const PropTypes = require("prop-types")
3
- const React = require("react")
1
+ import EventEmitter from "events"
2
+ import PropTypes from "prop-types"
3
+ import React from "react"
4
4
 
5
5
  export default class ApiMakerEventEmitterListener extends React.PureComponent {
6
6
  static propTypes = {
@@ -1,6 +1,6 @@
1
- const PropTypes = require("prop-types")
2
- const propTypesExact = require("prop-types-exact")
3
- const React = require("react")
1
+ import PropTypes from "prop-types"
2
+ import propTypesExact from "prop-types-exact"
3
+ import React from "react"
4
4
 
5
5
  export default class ApiMakerEventListener extends React.PureComponent {
6
6
  static callEvent (target, eventName, args = []) {
@@ -1,7 +1,7 @@
1
- const ModelEvents = require("./model-events.cjs")
2
- const PropTypes = require("prop-types")
3
- const propTypesExact = require("prop-types-exact")
4
- const React = require("react")
1
+ import ModelEvents from "./model-events.mjs"
2
+ import PropTypes from "prop-types"
3
+ import propTypesExact from "prop-types-exact"
4
+ import React from "react"
5
5
 
6
6
  export default class ApiMakerEventModelClass extends React.PureComponent {
7
7
  static propTypes = propTypesExact({
@@ -1,8 +1,8 @@
1
- const debounce = require("debounce")
2
- const ModelEvents = require("./model-events.cjs")
3
- const PropTypes = require("prop-types")
4
- const propTypesExact = require("prop-types-exact")
5
- const React = require("react")
1
+ import debounce from "debounce"
2
+ import ModelEvents from "./model-events.mjs"
3
+ import PropTypes from "prop-types"
4
+ import propTypesExact from "prop-types-exact"
5
+ import React from "react"
6
6
 
7
7
  export default class ApiMakerEventUpdated extends React.PureComponent {
8
8
  static defaultProps = {
@@ -1,4 +1,4 @@
1
- const {digg} = require("diggerize")
1
+ import {digg} from "diggerize"
2
2
 
3
3
  const propTypesValidator = (expectedClassName, args = {}) => (props, propName, componentName) => {
4
4
  const prop = digg(props, propName)
@@ -26,4 +26,4 @@ const instanceOfClassName = (expectedClassName) => {
26
26
  return validator
27
27
  }
28
28
 
29
- module.exports = instanceOfClassName
29
+ export default instanceOfClassName
@@ -1,11 +1,12 @@
1
- const Params = require("./params.cjs")
1
+ import Params from "./params.mjs"
2
2
 
3
- module.exports = class KeyValueStore {
3
+ const shared = {}
4
+
5
+ export default class KeyValueStore {
4
6
  static current () {
5
- if (!global.currentKeyValueStore)
6
- global.currentKeyValueStore = new KeyValueStore()
7
+ if (!shared.currentKeyValueStore) shared.currentKeyValueStore = new KeyValueStore()
7
8
 
8
- return global.currentKeyValueStore
9
+ return shared.currentKeyValueStore
9
10
  }
10
11
 
11
12
  static get (key) {
@@ -1,11 +1,13 @@
1
- module.exports = class ApiMakerLogger {
1
+ const shared = {}
2
+
3
+ export default class ApiMakerLogger {
2
4
  static current () {
3
- if (!global.apiMakerLogger) {
4
- global.apiMakerLogger = new ApiMakerLogger()
5
- // global.apiMakerLogger.setDebug(true)
5
+ if (!shared.apiMakerLogger) {
6
+ shared.apiMakerLogger = new ApiMakerLogger()
7
+ // shared.apiMakerLogger.setDebug(true)
6
8
  }
7
9
 
8
- return global.apiMakerLogger
10
+ return shared.apiMakerLogger
9
11
  }
10
12
 
11
13
  static log (message) {
@@ -49,7 +49,7 @@ const mergeObjectsInto = (mergeInto, object) => {
49
49
  }
50
50
  }
51
51
 
52
- module.exports = {
52
+ export {
53
53
  merge,
54
54
  mergeArraysInto,
55
55
  mergeObjectsInto
@@ -0,0 +1,10 @@
1
+ import {digg} from "diggerize"
2
+ import inflection from "inflection"
3
+ import * as models from "@kaspernj/api-maker/src/models.mjs.erb"
4
+
5
+ export default (modelName) => {
6
+ const requireName = inflection.camelize(modelName)
7
+ const ModelClass = digg(models, requireName)
8
+
9
+ return ModelClass
10
+ }
@@ -1,7 +1,7 @@
1
- const CableConnectionPool = require("./cable-connection-pool.cjs")
2
- const {digg} = require("diggerize")
1
+ import CableConnectionPool from "./cable-connection-pool.mjs"
2
+ import {digg} from "diggerize"
3
3
 
4
- module.exports = class ModelEvents {
4
+ export default class ModelEvents {
5
5
  static connect (model, eventName, callback) {
6
6
  const modelClassName = digg(model.modelClassData(), "name")
7
7
  const cableSubscription = CableConnectionPool.current().connectEvent(modelClassName, model.primaryKey(), eventName, callback)
@@ -1,5 +1,5 @@
1
1
  import EventUpdated from "./event-updated"
2
- import Params from "./params.cjs"
2
+ import Params from "./params.mjs"
3
3
  import React from "react"
4
4
 
5
5
  export default (WrappedComponent, ModelClass, args = {}) => class modelLoadWrapper extends React.PureComponent {
@@ -8,7 +8,8 @@ export default (WrappedComponent, ModelClass, args = {}) => class modelLoadWrapp
8
8
 
9
9
  state = {
10
10
  model: undefined,
11
- modelId: this.props.match.params[this.paramsVariableName] || this.props.match.params.id
11
+ modelId: this.props.match.params[this.paramsVariableName] || this.props.match.params.id,
12
+ notFound: undefined
12
13
  }
13
14
 
14
15
  componentDidMount() {
@@ -37,7 +38,10 @@ export default (WrappedComponent, ModelClass, args = {}) => class modelLoadWrapp
37
38
 
38
39
  const model = await query.first()
39
40
 
40
- this.setState({model})
41
+ this.setState({
42
+ model,
43
+ notFound: !model
44
+ })
41
45
  }
42
46
 
43
47
  async loadNewModel() {
@@ -62,11 +66,12 @@ export default (WrappedComponent, ModelClass, args = {}) => class modelLoadWrapp
62
66
 
63
67
  render() {
64
68
  const {onUpdated, reloadModel} = digs(this, "onUpdated", "reloadModel")
65
- const {model, modelId} = digs(this.state, "model", "modelId")
69
+ const {model, modelId, notFound} = digs(this.state, "model", "modelId", "notFound")
66
70
  const wrappedComponentProps = {}
67
71
 
68
72
  wrappedComponentProps[this.camelizedLower] = model
69
73
  wrappedComponentProps[`${this.camelizedLower}Id`] = modelId
74
+ wrappedComponentProps[`${this.camelizedLower}NotFound`] = notFound
70
75
 
71
76
  return (
72
77
  <>
@@ -1,7 +1,7 @@
1
- const Config = require("@kaspernj/api-maker/src/config").default
1
+ import Config from "@kaspernj/api-maker/src/config.mjs"
2
2
 
3
- module.exports = class ModelName {
4
- constructor (data) {
3
+ export default class ModelName {
4
+ constructor(data) {
5
5
  this.data = data
6
6
  }
7
7
 
@@ -9,10 +9,10 @@ module.exports = class ModelName {
9
9
  return this.data.modelClassData.camelizedLower
10
10
  }
11
11
 
12
- human (args) {
12
+ human(args) {
13
13
  let argsToUse = args
14
14
 
15
- if (!argsToUse) argsToUse = {count: 1}
15
+ if (!argsToUse) argsToUse = { count: 1 }
16
16
 
17
17
  let countKey
18
18
 
@@ -1,7 +1,7 @@
1
- const {digg} = require("diggerize")
2
- const Inflection = require("inflection")
1
+ import {digg} from "diggerize"
2
+ import Inflection from "inflection"
3
3
 
4
- module.exports = class ApiMakerModelPropType {
4
+ export default class ApiMakerModelPropType {
5
5
  static ofModel (modelClass) {
6
6
  const modelPropTypeInstance = new ApiMakerModelPropType()
7
7
 
@@ -1,5 +1,5 @@
1
- import BaseModel from "./base-model.cjs"
2
- import Collection from "./collection.cjs"
1
+ import BaseModel from "./base-model.mjs"
2
+ import Collection from "./collection.mjs"
3
3
  import {digg, digs} from "diggerize"
4
4
  import inflection from "inflection"
5
5
 
@@ -1,9 +1,9 @@
1
- const {digg} = require("diggerize")
2
- const inflection = require("inflection")
3
- const modelClassRequire = require("./model-class-require.cjs")
4
- const Preloaded = require("./preloaded.cjs")
1
+ import {digg} from "diggerize"
2
+ import inflection from "inflection"
3
+ import modelClassRequire from "./model-class-require.mjs"
4
+ import Preloaded from "./preloaded.mjs"
5
5
 
6
- module.exports = class ModelsResponseReader {
6
+ export default class ModelsResponseReader {
7
7
  static first (response) {
8
8
  return ModelsResponseReader.collection(response)[0]
9
9
  }
@@ -0,0 +1,16 @@
1
+ /* rails-erb-loader-dependencies api_maker/resources/ models/ */
2
+
3
+ import {digg} from "diggerize"
4
+ import ModelRecipesLoader from "./model-recipes-loader.mjs"
5
+
6
+ const modelRecipes = <%= ApiMaker::ModelClassesJavaScriptGeneratorService.execute!.to_json %>
7
+ const loader = new ModelRecipesLoader({recipes: modelRecipes})
8
+ const result = loader.load()
9
+
10
+ <% model_class_names = [] %>
11
+ <% ApiMaker::ModelClassesJavaScriptGeneratorService.new.resources.each do |resource| %>
12
+ <% model_class_names << resource.short_name %>
13
+ const <%= resource.short_name %> = digg(result, "<%= resource.short_name %>")
14
+ <% end %>
15
+
16
+ export {<%= model_class_names.join(", ") %>}
@@ -1,8 +1,8 @@
1
- const Money = require("js-money")
2
- const formatNumber = require("format-number")
3
- const replaceall = require("replaceall")
1
+ import Money from "js-money"
2
+ import formatNumber from "format-number"
3
+ import replaceall from "replaceall"
4
4
 
5
- module.exports = class MoneyFormatter {
5
+ export default class MoneyFormatter {
6
6
  static fromMoney (money, args = {}) {
7
7
  return new MoneyFormatter(money, args)
8
8
  }
@@ -0,0 +1 @@
1
+ export default class NotLoadedError extends Error {}
@@ -1,10 +1,10 @@
1
- const formSerialize = require("form-serialize")
2
- const {merge} = require("./merge.cjs")
3
- const qs = require("qs")
1
+ import formSerialize from "form-serialize"
2
+ import {merge} from "./merge.mjs"
3
+ import qs from "qs"
4
4
 
5
- module.exports = class Params {
5
+ export default class Params {
6
6
  static parse () {
7
- return qs.parse(global.location.search.substr(1))
7
+ return qs.parse(globalThis.location.search.substr(1))
8
8
  }
9
9
 
10
10
  static change (given) {
@@ -1,7 +1,7 @@
1
- const inflection = require("inflection")
2
- const modelClassRequire = require("./model-class-require.cjs")
1
+ import inflection from "inflection"
2
+ import modelClassRequire from "./model-class-require.mjs"
3
3
 
4
- module.exports = class ApiMakerPreloaded {
4
+ export default class ApiMakerPreloaded {
5
5
  constructor (response) {
6
6
  this.response = response
7
7
  this.loadPreloadedModels()
@@ -1,4 +1,4 @@
1
- module.exports = class ApiMakerResult {
1
+ export default class ApiMakerResult {
2
2
  constructor (data) {
3
3
  this.data = data
4
4
  }
@@ -1,8 +1,8 @@
1
- const {dig, digg, digs} = require("diggerize")
2
- const inflection = require("inflection")
3
- const qs = require("qs")
1
+ import {dig, digg, digs} from "diggerize"
2
+ import inflection from "inflection"
3
+ import qs from "qs"
4
4
 
5
- module.exports = class ApiMakerRoutesNative {
5
+ export default class ApiMakerRoutesNative {
6
6
  constructor ({getLocale}) {
7
7
  this.getLocale = getLocale
8
8
  this.routeDefinitions = []
@@ -141,15 +141,15 @@ module.exports = class ApiMakerRoutesNative {
141
141
  addHostToRoute ({host, port, protocol, translatedRoute}) {
142
142
  let fullUrl = ""
143
143
 
144
- const hostToUse = host || global.location && global.location.host
145
- const portToUse = port || global.location && global.location.port
144
+ const hostToUse = host || globalThis.location && globalThis.location.host
145
+ const portToUse = port || globalThis.location && globalThis.location.port
146
146
 
147
147
  if (!hostToUse) throw new Error("Unable to detect host")
148
148
 
149
149
  if (protocol) {
150
150
  fullUrl += `${protocol}://`
151
- } else if (global.location && global.location.protocol) {
152
- fullUrl += `${global.location.protocol}//`
151
+ } else if (globalThis.location && globalThis.location.protocol) {
152
+ fullUrl += `${globalThis.location.protocol}//`
153
153
  } else {
154
154
  fullUrl += "https://"
155
155
  }
@@ -1,7 +1,7 @@
1
- const {digg} = require("diggerize")
2
- const inflection = require("inflection")
1
+ import {digg} from "diggerize"
2
+ import inflection from "inflection"
3
3
 
4
- module.exports = class ApiMakerRoutes {
4
+ export default class ApiMakerRoutes {
5
5
  constructor ({jsRoutes, locale, routeDefinitions}) {
6
6
  if (!jsRoutes) throw new Error("'jsRoutes' wasn't given")
7
7
 
@@ -1,6 +1,6 @@
1
- const {digg} = require("diggerize")
1
+ import {digg} from "diggerize"
2
2
 
3
- module.exports = class Serializer {
3
+ export default class Serializer {
4
4
  static serialize (arg) {
5
5
  const serialize = new Serializer(arg)
6
6
 
@@ -1,12 +1,12 @@
1
- const CommandsPool = require("./commands-pool.cjs")
1
+ import CommandsPool from "./commands-pool.mjs"
2
2
 
3
- module.exports = class ApiMakerServices {
3
+ const shared = {}
4
+
5
+ export default class ApiMakerServices {
4
6
  static current () {
5
- if (!global.currentApiMakerService) {
6
- global.currentApiMakerService = new ApiMakerServices()
7
- }
7
+ if (!shared.currentApiMakerService) shared.currentApiMakerService = new ApiMakerServices()
8
8
 
9
- return global.currentApiMakerService
9
+ return shared.currentApiMakerService
10
10
  }
11
11
 
12
12
  sendRequest (serviceName, args) {
@@ -1,6 +1,6 @@
1
- const stackTraceParser = require("stacktrace-parser")
2
- const {SourceMapConsumer} = require("source-map")
3
- const uniqunize = require("uniqunize")
1
+ import * as stackTraceParser from "stacktrace-parser"
2
+ import {SourceMapConsumer} from "source-map"
3
+ import uniqunize from "uniqunize"
4
4
 
5
5
  // Sometimes this needs to be called and sometimes not
6
6
  if (SourceMapConsumer.initialize) {
@@ -9,7 +9,7 @@ if (SourceMapConsumer.initialize) {
9
9
  })
10
10
  }
11
11
 
12
- module.exports = class SourceMapsLoader {
12
+ export default class SourceMapsLoader {
13
13
  constructor () {
14
14
  this.debug = false
15
15
  this.isLoadingSourceMaps = false
@@ -1,8 +1,8 @@
1
- const {digg} = require("diggerize")
2
- const ModelEvents = require("./model-events.cjs")
3
- const PropTypes = require("prop-types")
4
- const propTypesExact = require("prop-types-exact")
5
- const React = require("react")
1
+ import {digg} from "diggerize"
2
+ import ModelEvents from "./model-events.mjs"
3
+ import PropTypes from "prop-types"
4
+ import propTypesExact from "prop-types-exact"
5
+ import React from "react"
6
6
 
7
7
  export default class ApiMakerUpdatedAttribute extends React.PureComponent {
8
8
  static propTypes = propTypesExact({
@@ -1,5 +1,5 @@
1
- const BaseError = require("./base-error.cjs")
2
- const inflection = require("inflection")
1
+ import BaseError from "./base-error.mjs"
2
+ import inflection from "inflection"
3
3
 
4
4
  class ValidationError extends BaseError {
5
5
  constructor (validationErrors, args) {
@@ -28,4 +28,4 @@ class ValidationError extends BaseError {
28
28
 
29
29
  ValidationError.apiMakerType = "ValidationError"
30
30
 
31
- module.exports = ValidationError
31
+ export default ValidationError
@@ -1,6 +1,6 @@
1
- const {digg, digs} = require("diggerize")
2
- const inflection = require("inflection")
3
- const modelClassRequire = require("./model-class-require.cjs")
1
+ import {digg, digs} from "diggerize"
2
+ import inflection from "inflection"
3
+ import modelClassRequire from "./model-class-require.mjs"
4
4
 
5
5
  class ValidationError {
6
6
  constructor (args) {
@@ -127,7 +127,7 @@ class ValidationErrors {
127
127
  }
128
128
  }
129
129
 
130
- module.exports = {
130
+ export {
131
131
  ValidationError,
132
132
  ValidationErrors
133
133
  }
@@ -1,4 +1,4 @@
1
- import config from "./config"
1
+ import config from "./config.mjs"
2
2
  import escapeStringRegexp from "escape-string-regexp"
3
3
  import inflection from "inflection"
4
4
  import PropTypes from "prop-types"
@@ -1 +0,0 @@
1
- module.exports = class AttributeNotLoadedError extends Error {}
@@ -1,3 +0,0 @@
1
- const {createConsumer} = require("@rails/actioncable")
2
-
3
- module.exports = createConsumer()
@@ -1,9 +0,0 @@
1
- const {digg} = require("diggerize")
2
- const inflection = require("inflection")
3
-
4
- module.exports = (modelName) => {
5
- const requireName = inflection.camelize(modelName)
6
- const ModelClass = digg(require("@kaspernj/api-maker/src/models.cjs"), requireName)
7
-
8
- return ModelClass
9
- }
@@ -1,3 +0,0 @@
1
- /* rails-erb-loader-dependencies api_maker/resources/ models/ */
2
-
3
- export default <%= ApiMaker::ModelClassesJavaScriptGeneratorService.execute!.to_json %>
package/src/models.cjs DELETED
@@ -1,7 +0,0 @@
1
- const modelRecipes = require("./model-recipes.mjs.erb").default
2
- const ModelRecipesLoader = require("./model-recipes-loader.mjs").default
3
-
4
- const loader = new ModelRecipesLoader({recipes: modelRecipes})
5
- const result = loader.load()
6
-
7
- module.exports = result
@@ -1 +0,0 @@
1
- module.exports = class NotLoadedError extends Error {}