ballerina-core 1.0.31 → 1.0.33

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ballerina-core",
3
3
  "author": "Dr. Giuseppe Maggiore",
4
4
  "private": false,
5
- "version": "1.0.31",
5
+ "version": "1.0.33",
6
6
  "main": "main.ts",
7
7
  "dependencies": {
8
8
  "immutable": "^5.0.0-beta.5",
@@ -18,15 +18,13 @@ export const HandleApiResponse = <
18
18
  return AsyncState.Operations.isLoading(asyncState)
19
19
  ? CheckerCo.Do(() => {})
20
20
  : CheckerCo.Seq([
21
- CheckerCo.Do(() =>
22
- AsyncState.Operations.errors(asyncState).length > 0
23
- ? handlers.handleError?.(
24
- AsyncState.Operations.hasValue(asyncState)
25
- ? asyncState.value
26
- : undefined
27
- )
28
- : handlers.handleSuccess?.(_)
29
- ),
21
+ CheckerCo.Do(() => {
22
+ return AsyncState.Operations.status(asyncState) === 'error'
23
+ ? handlers.handleError?.(
24
+ asyncState.kind === 'error' ? asyncState.error : undefined
25
+ )
26
+ : handlers.handleSuccess?.(_)
27
+ }),
30
28
  CheckerCo.SetState((_) => ({
31
29
  ..._,
32
30
  ...ApiResponseChecker.Updaters.toChecked()(_),
@@ -40,7 +40,7 @@ export const editFormRunner = <E, FS>() => {
40
40
  Synchronize<Unit, ApiErrors, EditFormWritableState<E, FS>>(
41
41
  (_) =>
42
42
  current.entity.sync.kind == "loaded"
43
- ? current.api.update(current.entity.sync.value)
43
+ ? current.api.update(current.entityId, current.entity.sync.value)
44
44
  : Promise.resolve([]),
45
45
  (_) => "transient failure",
46
46
  5,
@@ -7,7 +7,7 @@ export type EditFormContext<E,FS> = {
7
7
  entityId:string,
8
8
  api:{
9
9
  get:(id: Guid) => Promise<E>,
10
- update:BasicFun<E, Promise<ApiErrors>>
10
+ update:(id: Guid, entity:E) => Promise<ApiErrors>
11
11
  },
12
12
  actualForm:Template<Value<E> & FS, FS, { onChange:SimpleCallback<BasicUpdater<E>>}>
13
13
  }
@@ -37,7 +37,7 @@ export const EditFormState = <E,FS>() => ({
37
37
  Template:{
38
38
  toChecked: () => ApiResponseChecker.Updaters.toChecked<EditFormState<E, FS>>(),
39
39
  toUnchecked: () => ApiResponseChecker.Updaters.toUnchecked<EditFormState<E, FS>>(),
40
- entity:(_:BasicUpdater<E>) : Updater<EditFormState<E,FS>> =>
40
+ entity:(_:BasicUpdater<E>) : Updater<EditFormState<E,FS>> =>
41
41
  EditFormState<E,FS>().Updaters.Core.entity(
42
42
  Synchronized.Updaters.sync(
43
43
  AsyncState.Operations.map(
@@ -24,7 +24,7 @@ const parseOptions = (leafPredicates: any, options: any) => {
24
24
  };
25
25
 
26
26
  export const FieldView = //<Context, FieldViews extends DefaultFieldViews, EnumFieldConfigs extends {}, EnumSources extends {}>() => <ViewType extends keyof FieldViews, ViewName extends keyof FieldViews[ViewType]>
27
- (fieldConfig:FieldConfig, fieldViews: any, viewType: any, viewName: any, fieldName: string, label: string, enumFieldConfigs: EnumOptionsSources, enumSources: any, leafPredicates: any): any => // FieldView<Context, FieldViews, ViewType, ViewName> =>
27
+ (fieldConfig:FieldConfig, fieldViews: any, viewType: any, viewName: any, fieldName: string, label: string, enumFieldConfigs: EnumOptionsSources, enumSources: any, leafPredicates: any): any => // FieldView<Context, FieldViews, ViewType, ViewName> =>
28
28
  {
29
29
  if (viewType == "maybeBoolean")
30
30
  return MaybeBooleanForm<any & FormLabel, Unit>()
@@ -330,7 +330,7 @@ export type EntityName = string
330
330
  export type EntityApis = {
331
331
  create: BasicFun<EntityName, BasicFun<any, Promise<Unit>>>
332
332
  default: BasicFun<EntityName, BasicFun<Unit, Promise<any>>>
333
- update: BasicFun<EntityName, BasicFun<any, Promise<ApiErrors>>>
333
+ update: BasicFun<EntityName, (id: Guid, entity: any) => Promise<ApiErrors>>
334
334
  get: BasicFun<EntityName, BasicFun<Guid, Promise<any>>>
335
335
  }
336
336
  export type EnumName = string
@@ -450,8 +450,8 @@ export const parseForms =
450
450
  const parsed = fromAPIRawValue({ kind: "lookup", name: parsedForm.formDef.type }, formsConfig.types, builtIns, apiConverters)(raw)
451
451
  return parsed
452
452
  }),
453
- update: (value: any) =>
454
- entityApis.update(launcher.api)(toAPIRawValue({ kind: "lookup", name: parsedForm.formDef.type }, formsConfig.types, builtIns, apiConverters)(value))
453
+ update: (id: Guid, value: any) =>
454
+ entityApis.update(launcher.api)(id, toAPIRawValue({ kind: "lookup", name: parsedForm.formDef.type }, formsConfig.types, builtIns, apiConverters)(value))
455
455
  }
456
456
  parsedLaunchers.edit = parsedLaunchers.edit.set(
457
457
  launcherName,
@@ -568,7 +568,7 @@ export const replaceKeywords = (obj: any, kind: "from api" | "to api"): any => {
568
568
  );
569
569
  } else if (typeof obj === "object" && obj !== null) {
570
570
  if(OrderedMap.isOrderedMap(obj)) {
571
- return obj.map((_, key) =>
571
+ return obj.map((_, key) =>
572
572
  replacementFn(key as string)
573
573
  )
574
574
  }