studiokit-scaffolding-js 4.3.12-alpha.3 → 4.3.12

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.
@@ -0,0 +1,172 @@
1
+ import React from 'react';
2
+ import { ComponentType } from 'react';
3
+ import { RouteComponentProps } from 'react-router';
4
+ import { Model } from 'studiokit-net-js';
5
+ export interface ModelContextDependencyVerifyComponentProps extends RouteComponentProps {
6
+ model: Model;
7
+ }
8
+ export declare function setupModelContextDependencyVerifyComponent<TOwnProps extends ModelContextDependencyVerifyComponentProps>(WrappedComponent: ComponentType<TOwnProps>, modelName: string, dependentModelName: string): {
9
+ new (props: TOwnProps | Readonly<TOwnProps>): {
10
+ render(): JSX.Element;
11
+ context: any;
12
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<TOwnProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
13
+ forceUpdate(callback?: (() => void) | undefined): void;
14
+ readonly props: Readonly<TOwnProps> & Readonly<{
15
+ children?: React.ReactNode;
16
+ }>;
17
+ state: Readonly<{}>;
18
+ refs: {
19
+ [key: string]: React.ReactInstance;
20
+ };
21
+ componentDidMount?(): void;
22
+ shouldComponentUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): boolean;
23
+ componentWillUnmount?(): void;
24
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
25
+ getSnapshotBeforeUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>): any;
26
+ componentDidUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>, snapshot?: any): void;
27
+ componentWillMount?(): void;
28
+ UNSAFE_componentWillMount?(): void;
29
+ componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
30
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
31
+ componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
32
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
33
+ };
34
+ new (props: TOwnProps, context: any): {
35
+ render(): JSX.Element;
36
+ context: any;
37
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<TOwnProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
38
+ forceUpdate(callback?: (() => void) | undefined): void;
39
+ readonly props: Readonly<TOwnProps> & Readonly<{
40
+ children?: React.ReactNode;
41
+ }>;
42
+ state: Readonly<{}>;
43
+ refs: {
44
+ [key: string]: React.ReactInstance;
45
+ };
46
+ componentDidMount?(): void;
47
+ shouldComponentUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): boolean;
48
+ componentWillUnmount?(): void;
49
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
50
+ getSnapshotBeforeUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>): any;
51
+ componentDidUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>, snapshot?: any): void;
52
+ componentWillMount?(): void;
53
+ UNSAFE_componentWillMount?(): void;
54
+ componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
55
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
56
+ componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
57
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
58
+ };
59
+ contextType?: React.Context<any> | undefined;
60
+ };
61
+ /**
62
+ * HOC that checks if the depender component is related to the dependee component.
63
+ *
64
+ * @param {*} WrappedComponent The component to wrap.
65
+ * @param {string} modelName The modelName of the dependent component itself.
66
+ * @param {string} dependentModelName The modelName that the dependent component depends on.
67
+ */
68
+ export default function modelContextDependencyVerifyComponent<TOwnProps extends ModelContextDependencyVerifyComponentProps>(WrappedComponent: ComponentType<TOwnProps>, modelName: string, dependentModelName: string): React.ComponentClass<import("react-router").Omit<TOwnProps, "match" | "location" | "history" | "staticContext"> & import("react-router").WithRouterProps<{
69
+ new (props: TOwnProps | Readonly<TOwnProps>): {
70
+ render(): JSX.Element;
71
+ context: any;
72
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<TOwnProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
73
+ forceUpdate(callback?: (() => void) | undefined): void;
74
+ readonly props: Readonly<TOwnProps> & Readonly<{
75
+ children?: React.ReactNode;
76
+ }>;
77
+ state: Readonly<{}>;
78
+ refs: {
79
+ [key: string]: React.ReactInstance;
80
+ };
81
+ componentDidMount?(): void;
82
+ shouldComponentUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): boolean;
83
+ componentWillUnmount?(): void;
84
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
85
+ getSnapshotBeforeUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>): any;
86
+ componentDidUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>, snapshot?: any): void;
87
+ componentWillMount?(): void;
88
+ UNSAFE_componentWillMount?(): void;
89
+ componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
90
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
91
+ componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
92
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
93
+ };
94
+ new (props: TOwnProps, context: any): {
95
+ render(): JSX.Element;
96
+ context: any;
97
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<TOwnProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
98
+ forceUpdate(callback?: (() => void) | undefined): void;
99
+ readonly props: Readonly<TOwnProps> & Readonly<{
100
+ children?: React.ReactNode;
101
+ }>;
102
+ state: Readonly<{}>;
103
+ refs: {
104
+ [key: string]: React.ReactInstance;
105
+ };
106
+ componentDidMount?(): void;
107
+ shouldComponentUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): boolean;
108
+ componentWillUnmount?(): void;
109
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
110
+ getSnapshotBeforeUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>): any;
111
+ componentDidUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>, snapshot?: any): void;
112
+ componentWillMount?(): void;
113
+ UNSAFE_componentWillMount?(): void;
114
+ componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
115
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
116
+ componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
117
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
118
+ };
119
+ contextType?: React.Context<any> | undefined;
120
+ }>, any> & import("react-router").WithRouterStatics<{
121
+ new (props: TOwnProps | Readonly<TOwnProps>): {
122
+ render(): JSX.Element;
123
+ context: any;
124
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<TOwnProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
125
+ forceUpdate(callback?: (() => void) | undefined): void;
126
+ readonly props: Readonly<TOwnProps> & Readonly<{
127
+ children?: React.ReactNode;
128
+ }>;
129
+ state: Readonly<{}>;
130
+ refs: {
131
+ [key: string]: React.ReactInstance;
132
+ };
133
+ componentDidMount?(): void;
134
+ shouldComponentUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): boolean;
135
+ componentWillUnmount?(): void;
136
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
137
+ getSnapshotBeforeUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>): any;
138
+ componentDidUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>, snapshot?: any): void;
139
+ componentWillMount?(): void;
140
+ UNSAFE_componentWillMount?(): void;
141
+ componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
142
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
143
+ componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
144
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
145
+ };
146
+ new (props: TOwnProps, context: any): {
147
+ render(): JSX.Element;
148
+ context: any;
149
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<TOwnProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
150
+ forceUpdate(callback?: (() => void) | undefined): void;
151
+ readonly props: Readonly<TOwnProps> & Readonly<{
152
+ children?: React.ReactNode;
153
+ }>;
154
+ state: Readonly<{}>;
155
+ refs: {
156
+ [key: string]: React.ReactInstance;
157
+ };
158
+ componentDidMount?(): void;
159
+ shouldComponentUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): boolean;
160
+ componentWillUnmount?(): void;
161
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
162
+ getSnapshotBeforeUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>): any;
163
+ componentDidUpdate?(prevProps: Readonly<TOwnProps>, prevState: Readonly<{}>, snapshot?: any): void;
164
+ componentWillMount?(): void;
165
+ UNSAFE_componentWillMount?(): void;
166
+ componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
167
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TOwnProps>, nextContext: any): void;
168
+ componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
169
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<TOwnProps>, nextState: Readonly<{}>, nextContext: any): void;
170
+ };
171
+ contextType?: React.Context<any> | undefined;
172
+ }>;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __assign = (this && this.__assign) || function () {
16
+ __assign = Object.assign || function(t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
+ t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.setupModelContextDependencyVerifyComponent = void 0;
31
+ var react_1 = __importDefault(require("react"));
32
+ var react_2 = require("react");
33
+ var react_router_dom_1 = require("react-router-dom");
34
+ function setupModelContextDependencyVerifyComponent(WrappedComponent, modelName, dependentModelName) {
35
+ return /** @class */ (function (_super) {
36
+ __extends(ModelContextVerifyComponent, _super);
37
+ function ModelContextVerifyComponent() {
38
+ return _super !== null && _super.apply(this, arguments) || this;
39
+ }
40
+ ModelContextVerifyComponent.prototype.render = function () {
41
+ var _a = this.props, params = _a.match.params, model = _a.model;
42
+ var routeParams = params;
43
+ var modelId = routeParams[modelName + "Id"] ? parseInt(routeParams[modelName + "Id"], 10) : undefined;
44
+ var dependentModelId = routeParams[dependentModelName + "Id"]
45
+ ? parseInt(routeParams[dependentModelName + "Id"], 10)
46
+ : undefined;
47
+ if (!!modelId &&
48
+ !!dependentModelId &&
49
+ model.id === modelId &&
50
+ model[dependentModelName + "Id"] === dependentModelId) {
51
+ return react_1.default.createElement(WrappedComponent, __assign({}, this.props));
52
+ }
53
+ return (react_1.default.createElement(react_router_dom_1.Redirect, { to: {
54
+ pathname: '/error'
55
+ } }));
56
+ };
57
+ return ModelContextVerifyComponent;
58
+ }(react_2.Component));
59
+ }
60
+ exports.setupModelContextDependencyVerifyComponent = setupModelContextDependencyVerifyComponent;
61
+ /**
62
+ * HOC that checks if the depender component is related to the dependee component.
63
+ *
64
+ * @param {*} WrappedComponent The component to wrap.
65
+ * @param {string} modelName The modelName of the dependent component itself.
66
+ * @param {string} dependentModelName The modelName that the dependent component depends on.
67
+ */
68
+ function modelContextDependencyVerifyComponent(WrappedComponent, modelName, dependentModelName) {
69
+ var component = setupModelContextDependencyVerifyComponent(WrappedComponent, modelName, dependentModelName);
70
+ return react_router_dom_1.withRouter(component);
71
+ }
72
+ exports.default = modelContextDependencyVerifyComponent;
@@ -1,5 +1,6 @@
1
1
  import React, { ComponentType } from 'react';
2
2
  import { Model } from 'studiokit-net-js';
3
+ import { CollectionComponentWrappedProps } from './CollectionComponent';
3
4
  import { CollectionItemComponentWrappedProps } from './CollectionItemComponent';
4
5
  /**
5
6
  * This component exists as a child to CollectionItemComponent to
@@ -13,7 +14,7 @@ import { CollectionItemComponentWrappedProps } from './CollectionItemComponent';
13
14
  * @param WrappedComponent Wrapped component that depends on the model. (Usually AsyncComponent)
14
15
  * @returns A wrapped component or redirects
15
16
  */
16
- export default function modelErrorRedirectComponent<TOwnProps extends CollectionItemComponentWrappedProps<Model>>(WrappedComponent: ComponentType<TOwnProps>): {
17
+ export default function modelErrorRedirectComponent<TOwnProps extends CollectionItemComponentWrappedProps<Model> | CollectionComponentWrappedProps<Model>>(WrappedComponent: ComponentType<TOwnProps>): {
17
18
  new (props: TOwnProps | Readonly<TOwnProps>): {
18
19
  render(): JSX.Element;
19
20
  context: any;
@@ -1,7 +1,7 @@
1
1
  import { Model, ModelCollection } from 'studiokit-net-js';
2
2
  import MODEL_STATUS from '../constants/modelStatus';
3
3
  export declare const getModelArray: <T extends Model>(model: ModelCollection<T>, guid?: string | undefined) => T[];
4
- export declare const getModelMinusRelations: <T extends Model>(model: T) => T;
4
+ export declare const getModelMinusRelations: <T extends Model>(model: T) => Partial<T>;
5
5
  export declare const getModelFetchResult: <T extends Model>(model?: T | undefined, nextModel?: T | undefined) => {
6
6
  isFinished: boolean;
7
7
  isSuccess: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "studiokit-scaffolding-js",
3
- "version": "4.3.12-alpha.3",
3
+ "version": "4.3.12",
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",