structured-fw 0.8.41 → 0.8.43

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 (90) hide show
  1. package/README.md +92 -10
  2. package/package.json +10 -3
  3. package/app/models/README.md +0 -9
  4. package/app/routes/README.md +0 -19
  5. package/app/views/README.md +0 -1
  6. package/app/views/layout.html +0 -1
  7. package/build/Config.d.ts +0 -2
  8. package/build/Config.js +0 -30
  9. package/build/app/Types.d.ts +0 -5
  10. package/build/app/Types.js +0 -1
  11. package/build/app/global.d.ts +0 -3
  12. package/build/app/global.js +0 -1
  13. package/build/app/models/Users.d.ts +0 -0
  14. package/build/app/models/Users.js +0 -1
  15. package/build/app/routes/Auth.d.ts +0 -0
  16. package/build/app/routes/Auth.js +0 -1
  17. package/build/app/routes/Test.d.ts +0 -2
  18. package/build/app/routes/Test.js +0 -101
  19. package/build/app/routes/Todo.d.ts +0 -0
  20. package/build/app/routes/Todo.js +0 -1
  21. package/build/app/routes/Upload.d.ts +0 -0
  22. package/build/app/routes/Upload.js +0 -1
  23. package/build/app/routes/Validation.d.ts +0 -2
  24. package/build/app/routes/Validation.js +0 -34
  25. package/build/app/routess/Auth.d.ts +0 -0
  26. package/build/app/routess/Auth.js +0 -1
  27. package/build/app/routess/Test.d.ts +0 -2
  28. package/build/app/routess/Test.js +0 -101
  29. package/build/app/routess/Todo.d.ts +0 -0
  30. package/build/app/routess/Todo.js +0 -1
  31. package/build/app/routess/Upload.d.ts +0 -0
  32. package/build/app/routess/Upload.js +0 -1
  33. package/build/app/routess/Validation.d.ts +0 -2
  34. package/build/app/routess/Validation.js +0 -34
  35. package/build/app/views/components/ClientImport/ClientImport.client.d.ts +0 -2
  36. package/build/app/views/components/ClientImport/ClientImport.client.js +0 -4
  37. package/build/app/views/components/ClientImport/Export.d.ts +0 -1
  38. package/build/app/views/components/ClientImport/Export.js +0 -1
  39. package/build/app/views/components/Conditionals/Conditionals.client.d.ts +0 -2
  40. package/build/app/views/components/Conditionals/Conditionals.client.js +0 -43
  41. package/build/app/views/components/FormTest/FormTestNested/FormTestNested.d.ts +0 -8
  42. package/build/app/views/components/FormTest/FormTestNested/FormTestNested.js +0 -7
  43. package/build/app/views/components/ModelsTest/ModelsTest.client.d.ts +0 -2
  44. package/build/app/views/components/ModelsTest/ModelsTest.client.js +0 -5
  45. package/build/app/views/components/MultipartForm/MultipartForm.client.d.ts +0 -0
  46. package/build/app/views/components/MultipartForm/MultipartForm.client.js +0 -1
  47. package/build/app/views/components/PassObject/PassObject.d.ts +0 -10
  48. package/build/app/views/components/PassObject/PassObject.js +0 -10
  49. package/build/app/views/components/PassObject/ReceiveObj/ReceiveObj.d.ts +0 -6
  50. package/build/app/views/components/PassObject/ReceiveObj/ReceiveObj.js +0 -6
  51. package/build/app/views/components/RedrawAbort/RedrawAbort.client.d.ts +0 -2
  52. package/build/app/views/components/RedrawAbort/RedrawAbort.client.js +0 -6
  53. package/build/app/views/components/RedrawAbort/RedrawAbort.d.ts +0 -8
  54. package/build/app/views/components/RedrawAbort/RedrawAbort.js +0 -8
  55. package/build/app/views/components/ServerSideContext/ServerSideContext.d.ts +0 -7
  56. package/build/app/views/components/ServerSideContext/ServerSideContext.js +0 -10
  57. package/build/assets/ts/Export.d.ts +0 -1
  58. package/build/assets/ts/Export.js +0 -1
  59. package/build/index.d.ts +0 -1
  60. package/build/index.js +0 -8
  61. package/build/tsconfig.tsbuildinfo +0 -1
  62. package/jsr.json +0 -35
  63. package/system/EventEmitter.ts +0 -38
  64. package/system/Helpers.ts +0 -97
  65. package/system/Symbols.ts +0 -6
  66. package/system/Types.ts +0 -232
  67. package/system/Util.ts +0 -488
  68. package/system/bin/structured.ts +0 -115
  69. package/system/client/App.ts +0 -11
  70. package/system/client/Client.ts +0 -9
  71. package/system/client/ClientComponent.ts +0 -1107
  72. package/system/client/DataStore.ts +0 -101
  73. package/system/client/DataStoreView.ts +0 -82
  74. package/system/client/Net.ts +0 -58
  75. package/system/client/NetRequest.ts +0 -64
  76. package/system/global.d.ts +0 -12
  77. package/system/server/Application.ts +0 -239
  78. package/system/server/Component.ts +0 -409
  79. package/system/server/Components.ts +0 -114
  80. package/system/server/Cookies.ts +0 -29
  81. package/system/server/Document.ts +0 -163
  82. package/system/server/DocumentHead.ts +0 -150
  83. package/system/server/FormValidation.ts +0 -231
  84. package/system/server/Handlebars.ts +0 -51
  85. package/system/server/Request.ts +0 -502
  86. package/system/server/Session.ts +0 -151
  87. package/system/server/dom/DOMFragment.ts +0 -7
  88. package/system/server/dom/DOMNode.ts +0 -140
  89. package/system/server/dom/HTMLParser.ts +0 -238
  90. package/tsconfig.json +0 -31
package/system/Types.ts DELETED
@@ -1,232 +0,0 @@
1
- import { IncomingMessage, ServerResponse } from "node:http";
2
- import { Application } from "./server/Application.js";
3
- import { symbolArrays } from "./Symbols.js";
4
- import { Net } from './client/Net.js';
5
- import { ClientComponent } from './client/ClientComponent.js';
6
- import { Component } from "./server/Component.js";
7
-
8
- export type StructuredConfig = {
9
- readonly envPrefix?: string,
10
- readonly autoInit: boolean,
11
- url: {
12
- removeTrailingSlash: boolean,
13
- componentRender: false | string,
14
- isAsset: (url: string) => boolean
15
- },
16
- routes: {
17
- readonly path: string
18
- },
19
- components: {
20
- readonly path: string,
21
- readonly componentNameAttribute: string
22
- },
23
- session: {
24
- readonly cookieName: string,
25
- readonly keyLength: number,
26
- readonly durationSeconds: number,
27
- readonly garbageCollectIntervalSeconds: number
28
- },
29
- http: {
30
- host?: string,
31
- port: number,
32
- linkHeaderRel: 'preload' | 'preconnect'
33
- },
34
- readonly runtime: 'Node.js' | 'Deno'
35
- }
36
-
37
- export type StructuredClientConfig = {
38
- componentRender: StructuredConfig['url']['componentRender'],
39
- componentNameAttribute: string
40
- }
41
-
42
- export type RequestMethod = 'GET'|'POST'|'PUT'|'PATCH'|'DELETE';
43
-
44
- export type RequestCallback<R extends any, Body extends LooseObject | undefined> = (ctx: RequestContext<Body>) => Promise<R>
45
-
46
- export type RequestHandler = {
47
- match: Array<URISegmentPattern>|RegExp,
48
- methods: Array<RequestMethod>,
49
- callback: RequestCallback<any, LooseObject | undefined>,
50
- scope: any,
51
-
52
- // if true, no (before/after)RequestHandler event is emitted, body and GET args not parsed
53
- staticAsset: boolean
54
- }
55
-
56
- export type RequestContext<Body extends LooseObject | undefined = LooseObject> = {
57
- request: IncomingMessage,
58
- response: ServerResponse,
59
- args: URIArguments,
60
- handler: null|RequestHandler,
61
-
62
- cookies: Record<string, string>,
63
-
64
- // POSTed data, parsed to object
65
- body: Body,
66
-
67
- bodyRaw?: Buffer,
68
-
69
- // files extracted from request body
70
- // currently only multipart/form-data
71
- files?: Record<string, RequestBodyRecordValue>,
72
-
73
- // user defined data
74
- data: RequestContextData,
75
-
76
- // if session is started and user has visited any page
77
- sessionId?: string,
78
-
79
- // true if x-requested-with header is received and it equals 'xmlhttprequest'
80
- isAjax: boolean,
81
-
82
- getArgs: PostedDataDecoded,
83
-
84
- respondWith: (data: any) => void,
85
- redirect: (to: string, statusCode?: number) => void,
86
- show404: () => Promise<void>
87
- }
88
-
89
- export type PostedDataDecoded = Record<string, string | boolean | Array<string | boolean | PostedDataDecoded> | Record<string, string | boolean | Array<string | boolean | PostedDataDecoded>> | Record<string, string | boolean | Array<string | boolean>>>
90
-
91
- export type RequestBodyRecordValue = string | Array<RequestBodyRecordValue> | { [key: string]: RequestBodyRecordValue } | { [key: string]: RequestBodyFile } | Array<RequestBodyFile> | RequestBodyFile;
92
-
93
- export interface RequestBodyArguments {
94
- [key: string] : RequestBodyRecordValue,
95
- [symbolArrays]? : {
96
- [key: string] : Array<string>
97
- }
98
- }
99
-
100
- export type RequestBodyFiles = {
101
- [key: string] : RequestBodyFile
102
- }
103
-
104
- export type RequestBodyFile = {
105
- fileName: string,
106
- data: Buffer,
107
- type: string
108
- }
109
-
110
- export type URISegmentPattern = {
111
- pattern: string|RegExp,
112
- name?: string,
113
- type?: 'string'|'number'
114
- }
115
-
116
- export type URIArguments = {
117
- [key: string] : string|number|RegExpExecArray
118
- }
119
-
120
- export type DocumentResource = {
121
- path: string,
122
- attributes: Record<string, string | null>,
123
- priority: number
124
- }
125
-
126
- export type ComponentEntry = {
127
- name: string,
128
- path: {
129
- absolute: string,
130
- relative: string,
131
- relativeToViews: string,
132
- build: string,
133
- html: string,
134
- jsServer?: string,
135
- jsClient?: string
136
- },
137
- hasJS: boolean,
138
- html : string,
139
-
140
- static: boolean,
141
-
142
- // server side component module
143
- module?: ComponentScaffold,
144
-
145
- // default is "div"
146
- renderTagName?: string,
147
-
148
- // if true, all component data is exported to ClientComponent
149
- exportData: boolean,
150
-
151
- // selectively export data to ClientComponent
152
- exportFields? : Array<string>,
153
-
154
- // attributes added to rendered DOM node
155
- attributes?: Record<string, string>,
156
-
157
- // client side component initializer
158
- initializer?: InitializerFunction
159
- }
160
-
161
- export interface ComponentScaffold {
162
- // rendered tag name (default is "div")
163
- tagName?: string,
164
-
165
- exportData?: boolean,
166
- // selectively export data
167
- exportFields? : Array<string>,
168
-
169
- static?: boolean,
170
- deferred?: (data: Record<string, any>, ctx: RequestContext | undefined, app: Application) => boolean,
171
-
172
- attributes?: Record<string, string>,
173
-
174
- getData: (this: ComponentScaffold, data: RequestBodyArguments|LooseObject, ctx: undefined|RequestContext, app: Application, component: Component) => Promise<LooseObject | null>
175
- [key: string] : any
176
- }
177
-
178
- export type LooseObject = Record<string, any>
179
-
180
- export type ApplicationEvents = 'serverStarted'|'beforeRequestHandler'|'afterRequestHandler'|'beforeRoutes'|'afterRoutes'|'beforeComponentsLoad'|'afterComponentsLoaded'|'documentCreated'|'beforeAssetAccess'|'afterAssetAccess'|'pageNotFound';
181
-
182
- export type SessionEntry = {
183
- sessionId : string,
184
- lastRequest: number,
185
- data: LooseObject
186
- }
187
-
188
- export type ValidationRuleWithArguments = [string, any];
189
- export type FormValidationEntry = {
190
- // field_name, human readable name
191
- field: [string, string],
192
- rules: Array<string|ValidationRuleWithArguments|ValidatorFunction>
193
- }
194
- export type ValidatorFunction = (data: PostedDataDecoded, field: string, arg: number, rules: Array<string|ValidationRuleWithArguments|ValidatorFunction>) => Promise<boolean>;
195
- export type ValidatorErrorDecorator = (fieldHumanReadable: string, data: PostedDataDecoded, field: string, arg: any) => string | Promise<string>;
196
- export type ValidationErrors = {
197
- [field: string] : Array<string>
198
- }
199
-
200
- export type ValidationErrorsSingle = {
201
- [field: string] : string
202
- }
203
-
204
- export type ValidationResult = {
205
- valid: boolean,
206
- errors: ValidationErrors|ValidationErrorsSingle
207
- }
208
-
209
- export type InitializerFunction = (this: ClientComponent, ctx : InitializerFunctionContext) => Promise<void>
210
-
211
- export type Initializers = {
212
- [key: string] : InitializerFunction
213
- }
214
-
215
- export type InitializerFunctionContext = {
216
- net: Net,
217
- isRedraw: boolean
218
- }
219
-
220
- export type StoreChangeCallback = (key: string, value: any, oldValue: any, componentId: string) => void
221
-
222
- export type AsteriskAny = '*';
223
-
224
- export type ClientComponentTransition = {
225
- fade: false|number,
226
- slide: false|number
227
- }
228
-
229
- export type ClientComponentTransitionEvent = 'show' | 'hide';
230
- export type ClientComponentTransitions = Record<ClientComponentTransitionEvent, ClientComponentTransition>;
231
-
232
- export type EventEmitterCallback<T> = (payload: T) => void