studiokit-scaffolding-js 7.0.5-alpha.3.6 → 7.0.5

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.
@@ -8,7 +8,7 @@ import { GuidComponentWrappedProps } from './GuidComponent';
8
8
  export interface CollectionComponentProps<TModel extends Model> extends CollectionCommonProps, GuidComponentWrappedProps, RouteComponentProps, CollectionReduxResponse<TModel> {
9
9
  }
10
10
  /** The props passed down to the `WrappedComponent`. */
11
- export interface CollectionComponentWrappedProps<TModel extends Model> extends CollectionCommonProps, GuidComponentWrappedProps, CollectionReduxResponse<TModel>, CollectionDerivedProps<TModel>, CollectionMethods, CollectionCommonState {
11
+ export interface CollectionComponentWrappedProps<TModel extends Model> extends Omit<CollectionComponentProps<TModel>, keyof RouteComponentProps>, CollectionDerivedProps<TModel>, CollectionMethods, CollectionCommonState {
12
12
  }
13
13
  export declare function configureCollectionComponent<TModel extends Model, TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & CollectionComponentWrappedProps<TModel>>, LoaderComponent?: ComponentType): {
14
14
  new (props: TOwnProps & CollectionComponentProps<TModel>): {
@@ -46,7 +46,7 @@ export declare function configureCollectionComponent<TModel extends Model, TOwnP
46
46
  };
47
47
  contextType?: React.Context<any> | undefined;
48
48
  };
49
- export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends {}>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps & GuidComponentWrappedProps & RouteComponentProps<{}, import("react-router").StaticContext, unknown> & CollectionCommonProps) => CollectionReduxResponse<TModel>;
49
+ export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends Pick<CollectionComponentProps<TModel>, "guid" | "match" | "modelName" | "pathParams" | "queryParams" | "location" | "history" | "staticContext" | "disableAutoLoad" | "disableAutoLoadOnParamsChange">>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps & Partial<CollectionComponentProps<TModel>>) => import("../../types").CollectionSelectorMethodResponse<Model>;
50
50
  /**
51
51
  * HOC that provides "collection" related functionality, using redux `connect()`, react-router-dom `withRouter()`, and `GuidComponent`.
52
52
  *
@@ -58,4 +58,4 @@ export declare const configureMapStateToProps: <TModel extends Model, TOwnProps
58
58
  * Can override at render time, e.g. `<C modelName="otherModel" />`.
59
59
  * @param LoaderComponent Component to use as the Loader. Defaults to `<Loading />`.
60
60
  */
61
- export default function collectionComponent<TModel extends Model, TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & CollectionComponentWrappedProps<TModel>>, modelName: string, LoaderComponent?: ComponentType): ComponentClass<TOwnProps & CollectionCommonProps>;
61
+ export default function collectionComponent<TModel extends Model, TOwnProps extends CollectionComponentWrappedProps<TModel>>(WrappedComponent: ComponentType<TOwnProps>, modelName: string, LoaderComponent?: ComponentType): ComponentClass<Omit<TOwnProps, keyof CollectionComponentWrappedProps<TModel>> & Partial<CollectionCommonProps>>;
@@ -142,22 +142,20 @@ function configureCollectionComponent(WrappedComponent, LoaderComponent) {
142
142
  if (modelStatus === modelStatus_1.MODEL_STATUS.UNINITIALIZED) {
143
143
  return react_1.default.createElement(LoaderComponent, null);
144
144
  }
145
- var wrappedProps = __assign(__assign({}, otherProps), { modelArray: this.getModelArray(this.props.model, this.props.guid), modelStatus: modelStatus, previousModelStatus: previousModelStatus, fetchingId: fetchingId, load: this.load, stopPeriodicLoad: this.stopPeriodicLoad, create: this.create, update: this.update, delete: this.delete });
146
- return react_1.default.createElement(WrappedComponent, __assign({}, wrappedProps));
145
+ return (react_1.default.createElement(WrappedComponent, __assign({}, otherProps, { modelArray: this.getModelArray(this.props.model, this.props.guid), modelStatus: modelStatus, previousModelStatus: previousModelStatus, fetchingId: fetchingId, load: this.load, stopPeriodicLoad: this.stopPeriodicLoad, create: this.create, update: this.update, delete: this.delete })));
147
146
  };
148
147
  return CollectionComponent;
149
148
  }(react_1.Component));
150
149
  }
151
150
  exports.configureCollectionComponent = configureCollectionComponent;
152
151
  var configureMapStateToProps = function (modelName) { return function (state, ownProps) {
153
- var _a = collection_1.selectCollectionFromState({
152
+ return collection_1.selectCollectionFromState({
154
153
  guid: ownProps.guid,
155
154
  modelName: ownProps.modelName || modelName,
156
155
  pathParams: ownProps.pathParams,
157
156
  routeMatchParams: ownProps.match.params,
158
157
  state: state
159
- }), model = _a.model, remaining = __rest(_a, ["model"]);
160
- return __assign(__assign({}, remaining), { model: model });
158
+ });
161
159
  }; };
162
160
  exports.configureMapStateToProps = configureMapStateToProps;
163
161
  /**
@@ -67,4 +67,4 @@ export declare function configureCollectionFirstItemComponent<TModel extends Mod
67
67
  };
68
68
  contextType?: React.Context<any> | undefined;
69
69
  };
70
- export default function collectionFirstItemComponent<TModel extends Model, TOwnProps extends {}>(wrappedComponent: ComponentType<TOwnProps & CollectionFirstItemComponentWrappedProps<TModel>>): ComponentClass<TOwnProps & CollectionComponentWrappedProps<TModel>>;
70
+ export default function collectionFirstItemComponent<TModel extends Model, TOwnProps extends CollectionFirstItemComponentWrappedProps<TModel>>(wrappedComponent: ComponentType<TOwnProps>): ComponentClass<Omit<TOwnProps, keyof CollectionFirstItemComponentWrappedProps<TModel>> & CollectionComponentWrappedProps<TModel>>;
@@ -95,6 +95,7 @@ function configureCollectionFirstItemComponent(WrappedComponent) {
95
95
  }
96
96
  exports.configureCollectionFirstItemComponent = configureCollectionFirstItemComponent;
97
97
  function collectionFirstItemComponent(wrappedComponent) {
98
+ // @ts-ignore: Could not match inferred type from HOC
98
99
  return configureCollectionFirstItemComponent(wrappedComponent);
99
100
  }
100
101
  exports.default = collectionFirstItemComponent;
@@ -45,7 +45,7 @@ export declare function configureCollectionItemComponent<TModel extends Model, T
45
45
  };
46
46
  contextType?: React.Context<any> | undefined;
47
47
  };
48
- export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends {}>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps & CollectionCommonProps & GuidComponentWrappedProps & RouteComponentProps<{}, import("react-router").StaticContext, unknown>) => CollectionItemReduxResponse<TModel>;
48
+ export declare const configureMapStateToProps: <TModel extends Model, TOwnProps extends Pick<CollectionItemComponentProps<TModel>, "guid" | "match" | "modelName" | "pathParams" | "queryParams" | "location" | "history" | "staticContext" | "disableAutoLoad" | "disableAutoLoadOnParamsChange">>(modelName: string) => (state: BaseReduxState, ownProps: TOwnProps) => import("../../types").CollectionSelectorMethodResponse<Model>;
49
49
  /**
50
50
  * HOC that provides "collection" related functionality for a single item in a collection, using redux `connect()`, react-router-dom `withRouter()`, and `GuidComponent`.
51
51
  *
@@ -57,4 +57,4 @@ export declare const configureMapStateToProps: <TModel extends Model, TOwnProps
57
57
  * Can override at render time, e.g. `<C modelName="otherModel" />`.
58
58
  * @param LoaderComponent Component to use as the Loader. Defaults to `<Loading />`.
59
59
  */
60
- export default function collectionItemComponent<TModel extends Model, TOwnProps extends {}>(WrappedComponent: ComponentType<TOwnProps & CollectionItemComponentWrappedProps<TModel>>, modelName: string, LoaderComponent?: ComponentType): ComponentClass<TOwnProps & CollectionCommonProps>;
60
+ export default function collectionItemComponent<TModel extends Model, TOwnProps extends CollectionItemComponentWrappedProps<TModel>>(WrappedComponent: ComponentType<TOwnProps>, modelName: string, LoaderComponent?: ComponentType): ComponentClass<Omit<TOwnProps, keyof CollectionItemComponentWrappedProps<TModel>> & Partial<CollectionCommonProps>>;
@@ -146,14 +146,13 @@ function configureCollectionItemComponent(WrappedComponent, LoaderComponent) {
146
146
  }
147
147
  exports.configureCollectionItemComponent = configureCollectionItemComponent;
148
148
  var configureMapStateToProps = function (modelName) { return function (state, ownProps) {
149
- var _a = collection_1.selectCollectionItemFromState({
149
+ return collection_1.selectCollectionItemFromState({
150
150
  guid: ownProps.guid,
151
151
  modelName: ownProps.modelName || modelName,
152
152
  pathParams: ownProps.pathParams,
153
153
  routeMatchParams: ownProps.match.params,
154
154
  state: state
155
- }), model = _a.model, remaining = __rest(_a, ["model"]);
156
- return __assign(__assign({}, remaining), { model: model });
155
+ });
157
156
  }; };
158
157
  exports.configureMapStateToProps = configureMapStateToProps;
159
158
  /**
@@ -134,6 +134,7 @@ function configureFullscreenModalComponent(WrappedComponent) {
134
134
  };
135
135
  FullscreenModalComponent.prototype.render = function () {
136
136
  var _a = this.props, contentLabel = _a.contentLabel, isTopOpenFullscreenModal = _a.isTopOpenFullscreenModal, onEntering = _a.onEntering, onExited = _a.onExited, _ = _a.isOpen, closeModal = _a.closeModal, guid = _a.guid, remainingProps = __rest(_a, ["contentLabel", "isTopOpenFullscreenModal", "onEntering", "onExited", "isOpen", "closeModal", "guid"]);
137
+ // do not pass ConnectedModalWrappedProps & GuidComponentWrappedProps to wrapped component
137
138
  var wrappedProps = __assign(__assign({}, remainingProps), { closeModal: this.closeModal });
138
139
  var isOpen = this.state.isOpen;
139
140
  return (react_1.default.createElement(react_modal_1.default, { isOpen: isOpen, contentLabel: contentLabel, style: {
@@ -107,5 +107,5 @@ export declare class UserRoles extends Component<UserRolesProps, UserRolesState>
107
107
  render(): React.JSX.Element;
108
108
  }
109
109
  export declare const mapStateToProps: (state: BaseReduxState, ownProps: UserRolesOwnProps) => UserRolesReduxProps;
110
- declare const _default: import("react-redux").ConnectedComponent<typeof UserRoles, Pick<React.ClassAttributes<UserRoles> & UserRolesProps, "guid" | "ref" | "modelName" | "pathParams" | "queryParams" | "externalProviders" | "model" | "key" | "readOnly" | "entityName" | "load" | "disableAutoLoad" | "disableAutoLoadOnParamsChange" | "modelStatus" | "previousModelStatus" | "fetchingId" | "modelArray" | "stopPeriodicLoad" | "create" | "update" | "delete" | "textForRole" | "defaultRole" | "roleDescriptions" | "renderAddDescription" | "isUpdateDisabled" | "isDeleteDisabled" | "allowMultipleRoles" | "requiredRole" | "isAddDisabled" | "modifyUserRoleActivityName" | "deleteOwnUserRoleActivityName" | "addRoleExcludeList" | "entity" | "filterUsers" | "onAdd" | "onUpdate" | "onRemove" | "renderTableDescription" | "lowercaseTextForRole" | "singularArticleForRole"> & UserRolesOwnProps>;
110
+ declare const _default: import("react-redux").ConnectedComponent<typeof UserRoles, Pick<React.ClassAttributes<UserRoles> & UserRolesProps, "guid" | "ref" | "modelName" | "pathParams" | "queryParams" | "externalProviders" | "model" | "key" | "readOnly" | "entityName" | "load" | "disableAutoLoad" | "disableAutoLoadOnParamsChange" | "modelArray" | "stopPeriodicLoad" | "create" | "update" | "delete" | "modelStatus" | "previousModelStatus" | "fetchingId" | "textForRole" | "defaultRole" | "roleDescriptions" | "renderAddDescription" | "isUpdateDisabled" | "isDeleteDisabled" | "allowMultipleRoles" | "requiredRole" | "isAddDisabled" | "modifyUserRoleActivityName" | "deleteOwnUserRoleActivityName" | "addRoleExcludeList" | "entity" | "filterUsers" | "onAdd" | "onUpdate" | "onRemove" | "renderTableDescription" | "lowercaseTextForRole" | "singularArticleForRole"> & UserRolesOwnProps>;
111
111
  export default _default;
@@ -160,7 +160,21 @@ function createCollectionItem(model, config, params) {
160
160
  if (model.id) {
161
161
  throw new Error('model already exists');
162
162
  }
163
- createItemInCollection(config, params);
163
+ var guid = config.guid, modelName = config.modelName, pathParams = config.pathParams, configQueryParams = config.queryParams, changeModelStatus = config.changeModelStatus;
164
+ var body = params.body, contentType = params.contentType, queryParams = params.queryParams;
165
+ if (pathParams && pathParams.length < route_1.getMinRequiredPathParamsCount(modelName)) {
166
+ throw new Error('pathParams length does not match length of path components');
167
+ }
168
+ changeModelStatus(constants_1.MODEL_STATUS.CREATING);
169
+ actionCreator_1.dispatchModelFetchRequest({
170
+ modelName: modelName,
171
+ guid: guid,
172
+ method: 'POST',
173
+ body: body,
174
+ pathParams: pathParams,
175
+ contentType: contentType,
176
+ queryParams: queryParams || configQueryParams
177
+ });
164
178
  }
165
179
  exports.createCollectionItem = createCollectionItem;
166
180
  //#endregion Create
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "studiokit-scaffolding-js",
3
- "version": "7.0.5-alpha.3.6",
3
+ "version": "7.0.5",
4
4
  "description": "Common scaffolding for Studio apps at Purdue",
5
5
  "repository": "https://gitlab.com/purdue-informatics/studiokit/studiokit-scaffolding-js",
6
6
  "license": "MIT",