@jumoo/processing 17.5.1 → 17.5.3

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.
@@ -19,10 +19,7 @@ export const createClient = (config = {}) => {
19
19
  serializedBody: undefined,
20
20
  };
21
21
  if (opts.security) {
22
- await setAuthParams({
23
- ...opts,
24
- security: opts.security,
25
- });
22
+ await setAuthParams(opts);
26
23
  }
27
24
  if (opts.requestValidator) {
28
25
  await opts.requestValidator(opts);
@@ -39,149 +36,134 @@ export const createClient = (config = {}) => {
39
36
  return { opts: resolvedOpts, url };
40
37
  };
41
38
  const request = async (options) => {
42
- const { opts, url } = await beforeRequest(options);
43
- const requestInit = {
44
- redirect: 'follow',
45
- ...opts,
46
- body: getValidRequestBody(opts),
47
- };
48
- let request = new Request(url, requestInit);
49
- for (const fn of interceptors.request.fns) {
50
- if (fn) {
51
- request = await fn(request, opts);
52
- }
53
- }
54
- // fetch must be assigned here, otherwise it would throw the error:
55
- // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
56
- const _fetch = opts.fetch;
39
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
40
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
41
+ let request;
57
42
  let response;
58
43
  try {
59
- response = await _fetch(request);
60
- }
61
- catch (error) {
62
- // Handle fetch exceptions (AbortError, network errors, etc.)
63
- let finalError = error;
64
- for (const fn of interceptors.error.fns) {
44
+ const { opts, url } = await beforeRequest(options);
45
+ const requestInit = {
46
+ redirect: 'follow',
47
+ ...opts,
48
+ body: getValidRequestBody(opts),
49
+ };
50
+ request = new Request(url, requestInit);
51
+ for (const fn of interceptors.request.fns) {
65
52
  if (fn) {
66
- finalError = (await fn(error, undefined, request, opts));
53
+ request = await fn(request, opts);
67
54
  }
68
55
  }
69
- finalError = finalError || {};
70
- if (opts.throwOnError) {
71
- throw finalError;
72
- }
73
- // Return error response
74
- return opts.responseStyle === 'data'
75
- ? undefined
76
- : {
77
- error: finalError,
78
- request,
79
- response: undefined,
80
- };
81
- }
82
- for (const fn of interceptors.response.fns) {
83
- if (fn) {
84
- response = await fn(response, request, opts);
56
+ // fetch must be assigned here, otherwise it would throw the error:
57
+ // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
58
+ const _fetch = opts.fetch;
59
+ response = await _fetch(request);
60
+ for (const fn of interceptors.response.fns) {
61
+ if (fn) {
62
+ response = await fn(response, request, opts);
63
+ }
85
64
  }
86
- }
87
- const result = {
88
- request,
89
- response,
90
- };
91
- if (response.ok) {
92
- const parseAs = (opts.parseAs === 'auto'
93
- ? getParseAs(response.headers.get('Content-Type'))
94
- : opts.parseAs) ?? 'json';
95
- if (response.status === 204 || response.headers.get('Content-Length') === '0') {
96
- let emptyData;
65
+ const result = {
66
+ request,
67
+ response,
68
+ };
69
+ if (response.ok) {
70
+ const parseAs = (opts.parseAs === 'auto'
71
+ ? getParseAs(response.headers.get('Content-Type'))
72
+ : opts.parseAs) ?? 'json';
73
+ if (response.status === 204 || response.headers.get('Content-Length') === '0') {
74
+ let emptyData;
75
+ switch (parseAs) {
76
+ case 'arrayBuffer':
77
+ case 'blob':
78
+ case 'text':
79
+ emptyData = await response[parseAs]();
80
+ break;
81
+ case 'formData':
82
+ emptyData = new FormData();
83
+ break;
84
+ case 'stream':
85
+ emptyData = response.body;
86
+ break;
87
+ case 'json':
88
+ default:
89
+ emptyData = {};
90
+ break;
91
+ }
92
+ return opts.responseStyle === 'data'
93
+ ? emptyData
94
+ : {
95
+ data: emptyData,
96
+ ...result,
97
+ };
98
+ }
99
+ let data;
97
100
  switch (parseAs) {
98
101
  case 'arrayBuffer':
99
102
  case 'blob':
103
+ case 'formData':
100
104
  case 'text':
101
- emptyData = await response[parseAs]();
105
+ data = await response[parseAs]();
102
106
  break;
103
- case 'formData':
104
- emptyData = new FormData();
107
+ case 'json': {
108
+ // Some servers return 200 with no Content-Length and empty body.
109
+ // response.json() would throw; read as text and parse if non-empty.
110
+ const text = await response.text();
111
+ data = text ? JSON.parse(text) : {};
105
112
  break;
113
+ }
106
114
  case 'stream':
107
- emptyData = response.body;
108
- break;
109
- case 'json':
110
- default:
111
- emptyData = {};
112
- break;
115
+ return opts.responseStyle === 'data'
116
+ ? response.body
117
+ : {
118
+ data: response.body,
119
+ ...result,
120
+ };
121
+ }
122
+ if (parseAs === 'json') {
123
+ if (opts.responseValidator) {
124
+ await opts.responseValidator(data);
125
+ }
126
+ if (opts.responseTransformer) {
127
+ data = await opts.responseTransformer(data);
128
+ }
113
129
  }
114
130
  return opts.responseStyle === 'data'
115
- ? emptyData
131
+ ? data
116
132
  : {
117
- data: emptyData,
133
+ data,
118
134
  ...result,
119
135
  };
120
136
  }
121
- let data;
122
- switch (parseAs) {
123
- case 'arrayBuffer':
124
- case 'blob':
125
- case 'formData':
126
- case 'text':
127
- data = await response[parseAs]();
128
- break;
129
- case 'json': {
130
- // Some servers return 200 with no Content-Length and empty body.
131
- // response.json() would throw; read as text and parse if non-empty.
132
- const text = await response.text();
133
- data = text ? JSON.parse(text) : {};
134
- break;
135
- }
136
- case 'stream':
137
- return opts.responseStyle === 'data'
138
- ? response.body
139
- : {
140
- data: response.body,
141
- ...result,
142
- };
137
+ const textError = await response.text();
138
+ let jsonError;
139
+ try {
140
+ jsonError = JSON.parse(textError);
143
141
  }
144
- if (parseAs === 'json') {
145
- if (opts.responseValidator) {
146
- await opts.responseValidator(data);
147
- }
148
- if (opts.responseTransformer) {
149
- data = await opts.responseTransformer(data);
142
+ catch {
143
+ // noop
144
+ }
145
+ throw jsonError ?? textError;
146
+ }
147
+ catch (error) {
148
+ let finalError = error;
149
+ for (const fn of interceptors.error.fns) {
150
+ if (fn) {
151
+ finalError = await fn(finalError, response, request, options);
150
152
  }
151
153
  }
152
- return opts.responseStyle === 'data'
153
- ? data
154
+ finalError = finalError || {};
155
+ if (throwOnError) {
156
+ throw finalError;
157
+ }
158
+ // TODO: we probably want to return error and improve types
159
+ return responseStyle === 'data'
160
+ ? undefined
154
161
  : {
155
- data,
156
- ...result,
162
+ error: finalError,
163
+ request,
164
+ response,
157
165
  };
158
166
  }
159
- const textError = await response.text();
160
- let jsonError;
161
- try {
162
- jsonError = JSON.parse(textError);
163
- }
164
- catch {
165
- // noop
166
- }
167
- const error = jsonError ?? textError;
168
- let finalError = error;
169
- for (const fn of interceptors.error.fns) {
170
- if (fn) {
171
- finalError = (await fn(error, response, request, opts));
172
- }
173
- }
174
- finalError = finalError || {};
175
- if (opts.throwOnError) {
176
- throw finalError;
177
- }
178
- // TODO: we probably want to return error and improve types
179
- return opts.responseStyle === 'data'
180
- ? undefined
181
- : {
182
- error: finalError,
183
- ...result,
184
- };
185
167
  };
186
168
  const makeMethodFn = (method) => (options) => request({ ...options, method });
187
169
  const makeSseFn = (method) => async (options) => {
@@ -189,7 +171,6 @@ export const createClient = (config = {}) => {
189
171
  return createSseClient({
190
172
  ...opts,
191
173
  body: opts.body,
192
- headers: opts.headers,
193
174
  method,
194
175
  onRequest: async (url, init) => {
195
176
  let request = new Request(url, init);
@@ -3,6 +3,8 @@ export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
3
3
  export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen';
4
4
  export { buildClientParams } from '../core/params.gen';
5
5
  export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
6
+ export type { ServerSentEventsResult } from '../core/serverSentEvents.gen';
7
+ export type { ClientMeta } from '../core/types.gen';
6
8
  export { createClient } from './client.gen';
7
9
  export type { Client, ClientOptions, Config, CreateClientConfig, Options, RequestOptions, RequestResult, ResolvedRequestOptions, ResponseStyle, TDataShape, } from './types.gen';
8
10
  export { createConfig, mergeHeaders } from './utils.gen';
@@ -63,6 +63,7 @@ export interface RequestOptions<TData = unknown, TResponseStyle extends Response
63
63
  url: Url;
64
64
  }
65
65
  export interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
66
+ headers: Headers;
66
67
  serializedBody?: string;
67
68
  }
68
69
  export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
@@ -76,8 +77,10 @@ export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extend
76
77
  data: undefined;
77
78
  error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
78
79
  }) & {
79
- request: Request;
80
- response: Response;
80
+ /** request may be undefined, because error may be from building the request object itself */
81
+ request?: Request;
82
+ /** response may be undefined, because error may be from building the request object itself or from a network error */
83
+ response?: Response;
81
84
  }>;
82
85
  export interface ClientOptions {
83
86
  baseUrl?: string;
@@ -85,7 +88,7 @@ export interface ClientOptions {
85
88
  throwOnError?: boolean;
86
89
  }
87
90
  type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
88
- type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
91
+ type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
89
92
  type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
90
93
  type BuildUrlFn = <TData extends {
91
94
  body?: unknown;
@@ -1,17 +1,21 @@
1
1
  import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
2
2
  import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
3
- export declare const createQuerySerializer: <T = unknown>({ parameters, ...args }?: QuerySerializerOptions) => (queryParams: T) => string;
3
+ export declare const createQuerySerializer: <T = unknown>({ parameters, ...args }?: QuerySerializerOptions) => ((queryParams: T) => string);
4
4
  /**
5
5
  * Infers parseAs value from provided Content-Type header.
6
6
  */
7
7
  export declare const getParseAs: (contentType: string | null) => Exclude<Config["parseAs"], "auto">;
8
- export declare const setAuthParams: ({ security, ...options }: Pick<Required<RequestOptions>, "security"> & Pick<RequestOptions, "auth" | "query"> & {
8
+ export declare function setAuthParams(options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
9
9
  headers: Headers;
10
- }) => Promise<void>;
10
+ }): Promise<void>;
11
11
  export declare const buildUrl: Client['buildUrl'];
12
12
  export declare const mergeConfigs: (a: Config, b: Config) => Config;
13
13
  export declare const mergeHeaders: (...headers: Array<Required<Config>["headers"] | undefined>) => Headers;
14
- type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
14
+ type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
15
+ /** response may be undefined due to a network error where no response object is produced */
16
+ response: Res | undefined,
17
+ /** request may be undefined, because error may be from building the request object itself */
18
+ request: Req | undefined, options: Options) => Err | Promise<Err>;
15
19
  type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
16
20
  type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
17
21
  declare class Interceptors<Interceptor> {
@@ -90,8 +90,8 @@ const checkForExistence = (options, name) => {
90
90
  }
91
91
  return false;
92
92
  };
93
- export const setAuthParams = async ({ security, ...options }) => {
94
- for (const auth of security) {
93
+ export async function setAuthParams(options) {
94
+ for (const auth of options.security ?? []) {
95
95
  if (checkForExistence(options, auth.name)) {
96
96
  continue;
97
97
  }
@@ -116,7 +116,7 @@ export const setAuthParams = async ({ security, ...options }) => {
116
116
  break;
117
117
  }
118
118
  }
119
- };
119
+ }
120
120
  export const buildUrl = (options) => getUrl({
121
121
  baseUrl: options.baseUrl,
122
122
  path: options.path,
@@ -1,4 +1,4 @@
1
- import { type ClientOptions, type Config } from './client';
1
+ import { type Client, type ClientOptions, type Config } from './client';
2
2
  import type { ClientOptions as ClientOptions2 } from './types.gen';
3
3
  /**
4
4
  * The `createClientConfig()` function will be called on client initialization
@@ -9,4 +9,4 @@ import type { ClientOptions as ClientOptions2 } from './types.gen';
9
9
  * to ensure your client always has the correct values.
10
10
  */
11
11
  export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
12
- export declare const client: import("./client").Client;
12
+ export declare const client: Client;
@@ -1,4 +1,3 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
- import { createClientConfig } from '../hey-api';
3
2
  import { createClient, createConfig } from './client';
4
- export const client = createClient(createClientConfig(createConfig({ baseUrl: 'http://localhost:41839', throwOnError: true })));
3
+ export const client = createClient(createConfig({ baseUrl: 'http://localhost:41839', throwOnError: true }));
@@ -6,6 +6,13 @@ export interface Auth {
6
6
  * @default 'header'
7
7
  */
8
8
  in?: 'header' | 'query' | 'cookie';
9
+ /**
10
+ * A unique identifier for the security scheme.
11
+ *
12
+ * Defined only when there are multiple security schemes whose `Auth`
13
+ * shape would otherwise be identical.
14
+ */
15
+ key?: string;
9
16
  /**
10
17
  * Header or query parameter name.
11
18
  *
@@ -34,10 +34,10 @@ export interface Fields {
34
34
  }
35
35
  export type FieldsConfig = ReadonlyArray<Field | Fields>;
36
36
  interface Params {
37
- body: unknown;
37
+ body?: unknown;
38
38
  headers: Record<string, unknown>;
39
39
  path: Record<string, unknown>;
40
40
  query: Record<string, unknown>;
41
41
  }
42
- export declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params;
42
+ export declare function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params;
43
43
  export {};
@@ -6,7 +6,7 @@ const extraPrefixesMap = {
6
6
  $query_: 'query',
7
7
  };
8
8
  const extraPrefixes = Object.entries(extraPrefixesMap);
9
- const buildKeyMap = (fields, map) => {
9
+ function buildKeyMap(fields, map) {
10
10
  if (!map) {
11
11
  map = new Map();
12
12
  }
@@ -29,22 +29,31 @@ const buildKeyMap = (fields, map) => {
29
29
  }
30
30
  }
31
31
  return map;
32
- };
33
- const stripEmptySlots = (params) => {
32
+ }
33
+ function stripEmptySlots(params) {
34
34
  for (const [slot, value] of Object.entries(params)) {
35
+ if (slot === 'body')
36
+ continue;
35
37
  if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
36
38
  delete params[slot];
37
39
  }
38
40
  }
39
- };
40
- export const buildClientParams = (args, fields) => {
41
+ }
42
+ export function buildClientParams(args, fields) {
41
43
  const params = {
42
- body: {},
43
- headers: {},
44
- path: {},
45
- query: {},
44
+ headers: Object.create(null),
45
+ path: Object.create(null),
46
+ query: Object.create(null),
46
47
  };
47
48
  const map = buildKeyMap(fields);
49
+ function writeSlot(slot, key, value) {
50
+ let record = params[slot];
51
+ if (record === undefined) {
52
+ record = Object.create(null);
53
+ params[slot] = record;
54
+ }
55
+ record[key] = value;
56
+ }
48
57
  let config;
49
58
  for (const [index, arg] of args.entries()) {
50
59
  if (fields[index]) {
@@ -58,7 +67,7 @@ export const buildClientParams = (args, fields) => {
58
67
  const field = map.get(config.key);
59
68
  const name = field.map || config.key;
60
69
  if (field.in) {
61
- params[field.in][name] = arg;
70
+ writeSlot(field.in, name, arg);
62
71
  }
63
72
  }
64
73
  else {
@@ -71,7 +80,7 @@ export const buildClientParams = (args, fields) => {
71
80
  if (field) {
72
81
  if (field.in) {
73
82
  const name = field.map || key;
74
- params[field.in][name] = value;
83
+ writeSlot(field.in, name, value);
75
84
  }
76
85
  else {
77
86
  params[field.map] = value;
@@ -81,12 +90,12 @@ export const buildClientParams = (args, fields) => {
81
90
  const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
82
91
  if (extra) {
83
92
  const [prefix, slot] = extra;
84
- params[slot][key.slice(prefix.length)] = value;
93
+ writeSlot(slot, key.slice(prefix.length), value);
85
94
  }
86
95
  else if ('allowExtra' in config && config.allowExtra) {
87
96
  for (const [slot, allowed] of Object.entries(config.allowExtra)) {
88
97
  if (allowed) {
89
- params[slot][key] = value;
98
+ writeSlot(slot, key, value);
90
99
  break;
91
100
  }
92
101
  }
@@ -97,4 +106,4 @@ export const buildClientParams = (args, fields) => {
97
106
  }
98
107
  stripEmptySlots(params);
99
108
  return params;
100
- };
109
+ }
@@ -7,7 +7,7 @@ export type JsonValue = null | string | number | boolean | JsonValue[] | {
7
7
  /**
8
8
  * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
9
9
  */
10
- export declare const queryKeyJsonReplacer: (_key: string, value: unknown) => {} | null | undefined;
10
+ export declare const queryKeyJsonReplacer: (_key: string, value: unknown) => unknown | undefined;
11
11
  /**
12
12
  * Safely stringifies a value and parses it back into a JsonValue.
13
13
  */
@@ -68,4 +68,4 @@ export interface StreamEvent<TData = unknown> {
68
68
  export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
69
69
  stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
70
70
  };
71
- export declare const createSseClient: <TData = unknown>({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }: ServerSentEventsOptions) => ServerSentEventsResult<TData>;
71
+ export declare function createSseClient<TData = unknown>({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }: ServerSentEventsOptions): ServerSentEventsResult<TData>;
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
- export const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
2
+ export function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
3
3
  let lastEventId;
4
4
  const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
5
5
  const createStream = async function* () {
@@ -53,8 +53,7 @@ export const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTra
53
53
  if (done)
54
54
  break;
55
55
  buffer += value;
56
- // Normalize line endings: CRLF -> LF, then CR -> LF
57
- buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
56
+ buffer = buffer.replace(/\r\n?/g, '\n'); // normalize line endings
58
57
  const chunks = buffer.split('\n\n');
59
58
  buffer = chunks.pop() ?? '';
60
59
  for (const chunk of chunks) {
@@ -130,4 +129,4 @@ export const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTra
130
129
  };
131
130
  const stream = createStream();
132
131
  return { stream };
133
- };
132
+ }
@@ -71,6 +71,11 @@ export interface Config {
71
71
  */
72
72
  responseValidator?: (data: unknown) => Promise<unknown>;
73
73
  }
74
+ /**
75
+ * Arbitrary metadata passed through the `meta` request option.
76
+ */
77
+ export interface ClientMeta {
78
+ }
74
79
  type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] ? true : [T] extends [never | undefined] ? [undefined] extends [T] ? false : true : false;
75
80
  export type OmitNever<T extends Record<string, unknown>> = {
76
81
  [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
@@ -1,4 +1,4 @@
1
- import type { Client, Options as Options2, TDataShape } from './client';
1
+ import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client';
2
2
  import type { CancelPipelineData, CancelPipelineErrors, CancelPipelineResponses, ClearPipelineData, ClearPipelineErrors, ClearPipelineResponses, CreatePipelineData, CreatePipelineErrors, CreatePipelineResponses, DeleteData, DeleteErrors, DeleteResponses, GetPipelineData, GetPipelineErrors, GetPipelineResponses, GetProcessorsData, GetProcessorsErrors, GetProcessorsResponses, GetResultsData, GetResultsErrors, GetResultsResponses, ListPipelinesByStrategyData, ListPipelinesByStrategyErrors, ListPipelinesByStrategyResponses, ListPipelinesData, ListPipelinesErrors, ListPipelinesResponses, ListQueueData, ListQueueErrors, ListQueueResponses, PeekItemData, PeekItemErrors, PeekItemResponses, PipelineStatusData, PipelineStatusErrors, PipelineStatusResponses, ProcessData, ProcessErrors, ProcessPipelineData, ProcessPipelineErrors, ProcessPipelineResponses, ProcessResponses, ReattachPipelineData, ReattachPipelineErrors, ReattachPipelineResponses, StartPipelineData, StartPipelineErrors, StartPipelineResponses, UpdatePipelineData, UpdatePipelineErrors, UpdatePipelineResponses } from './types.gen';
3
3
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
4
4
  /**
@@ -11,32 +11,32 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
11
11
  * You can pass arbitrary values through the `meta` object. This can be
12
12
  * used to access values that aren't defined as part of the SDK function.
13
13
  */
14
- meta?: Record<string, unknown>;
14
+ meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
15
15
  };
16
16
  export declare class PipelinesService {
17
- static cancelPipeline<ThrowOnError extends boolean = true>(options: Options<CancelPipelineData, ThrowOnError>): import("./client").RequestResult<CancelPipelineResponses, CancelPipelineErrors, ThrowOnError, "fields">;
18
- static clearPipeline<ThrowOnError extends boolean = true>(options: Options<ClearPipelineData, ThrowOnError>): import("./client").RequestResult<ClearPipelineResponses, ClearPipelineErrors, ThrowOnError, "fields">;
19
- static createPipeline<ThrowOnError extends boolean = true>(options?: Options<CreatePipelineData, ThrowOnError>): import("./client").RequestResult<CreatePipelineResponses, CreatePipelineErrors, ThrowOnError, "fields">;
20
- static getPipeline<ThrowOnError extends boolean = true>(options: Options<GetPipelineData, ThrowOnError>): import("./client").RequestResult<GetPipelineResponses, GetPipelineErrors, ThrowOnError, "fields">;
21
- static getProcessors<ThrowOnError extends boolean = true>(options?: Options<GetProcessorsData, ThrowOnError>): import("./client").RequestResult<GetProcessorsResponses, GetProcessorsErrors, ThrowOnError, "fields">;
22
- static getResults<ThrowOnError extends boolean = true>(options: Options<GetResultsData, ThrowOnError>): import("./client").RequestResult<GetResultsResponses, GetResultsErrors, ThrowOnError, "fields">;
23
- static listPipelines<ThrowOnError extends boolean = true>(options: Options<ListPipelinesData, ThrowOnError>): import("./client").RequestResult<ListPipelinesResponses, ListPipelinesErrors, ThrowOnError, "fields">;
24
- static listPipelinesByStrategy<ThrowOnError extends boolean = true>(options: Options<ListPipelinesByStrategyData, ThrowOnError>): import("./client").RequestResult<ListPipelinesByStrategyResponses, ListPipelinesByStrategyErrors, ThrowOnError, "fields">;
25
- static pipelineStatus<ThrowOnError extends boolean = true>(options: Options<PipelineStatusData, ThrowOnError>): import("./client").RequestResult<PipelineStatusResponses, PipelineStatusErrors, ThrowOnError, "fields">;
26
- static processPipeline<ThrowOnError extends boolean = true>(options: Options<ProcessPipelineData, ThrowOnError>): import("./client").RequestResult<ProcessPipelineResponses, ProcessPipelineErrors, ThrowOnError, "fields">;
27
- static reattachPipeline<ThrowOnError extends boolean = true>(options: Options<ReattachPipelineData, ThrowOnError>): import("./client").RequestResult<ReattachPipelineResponses, ReattachPipelineErrors, ThrowOnError, "fields">;
28
- static startPipeline<ThrowOnError extends boolean = true>(options?: Options<StartPipelineData, ThrowOnError>): import("./client").RequestResult<StartPipelineResponses, StartPipelineErrors, ThrowOnError, "fields">;
29
- static updatePipeline<ThrowOnError extends boolean = true>(options: Options<UpdatePipelineData, ThrowOnError>): import("./client").RequestResult<UpdatePipelineResponses, UpdatePipelineErrors, ThrowOnError, "fields">;
17
+ static cancelPipeline<ThrowOnError extends boolean = true>(options: Options<CancelPipelineData, ThrowOnError>): RequestResult<CancelPipelineResponses, CancelPipelineErrors, ThrowOnError>;
18
+ static clearPipeline<ThrowOnError extends boolean = true>(options: Options<ClearPipelineData, ThrowOnError>): RequestResult<ClearPipelineResponses, ClearPipelineErrors, ThrowOnError>;
19
+ static createPipeline<ThrowOnError extends boolean = true>(options?: Options<CreatePipelineData, ThrowOnError>): RequestResult<CreatePipelineResponses, CreatePipelineErrors, ThrowOnError>;
20
+ static getPipeline<ThrowOnError extends boolean = true>(options: Options<GetPipelineData, ThrowOnError>): RequestResult<GetPipelineResponses, GetPipelineErrors, ThrowOnError>;
21
+ static getProcessors<ThrowOnError extends boolean = true>(options?: Options<GetProcessorsData, ThrowOnError>): RequestResult<GetProcessorsResponses, GetProcessorsErrors, ThrowOnError>;
22
+ static getResults<ThrowOnError extends boolean = true>(options: Options<GetResultsData, ThrowOnError>): RequestResult<GetResultsResponses, GetResultsErrors, ThrowOnError>;
23
+ static listPipelines<ThrowOnError extends boolean = true>(options: Options<ListPipelinesData, ThrowOnError>): RequestResult<ListPipelinesResponses, ListPipelinesErrors, ThrowOnError>;
24
+ static listPipelinesByStrategy<ThrowOnError extends boolean = true>(options: Options<ListPipelinesByStrategyData, ThrowOnError>): RequestResult<ListPipelinesByStrategyResponses, ListPipelinesByStrategyErrors, ThrowOnError>;
25
+ static pipelineStatus<ThrowOnError extends boolean = true>(options: Options<PipelineStatusData, ThrowOnError>): RequestResult<PipelineStatusResponses, PipelineStatusErrors, ThrowOnError>;
26
+ static processPipeline<ThrowOnError extends boolean = true>(options: Options<ProcessPipelineData, ThrowOnError>): RequestResult<ProcessPipelineResponses, ProcessPipelineErrors, ThrowOnError>;
27
+ static reattachPipeline<ThrowOnError extends boolean = true>(options: Options<ReattachPipelineData, ThrowOnError>): RequestResult<ReattachPipelineResponses, ReattachPipelineErrors, ThrowOnError>;
28
+ static startPipeline<ThrowOnError extends boolean = true>(options?: Options<StartPipelineData, ThrowOnError>): RequestResult<StartPipelineResponses, StartPipelineErrors, ThrowOnError>;
29
+ static updatePipeline<ThrowOnError extends boolean = true>(options: Options<UpdatePipelineData, ThrowOnError>): RequestResult<UpdatePipelineResponses, UpdatePipelineErrors, ThrowOnError>;
30
30
  }
31
31
  export declare class QueuesService {
32
- static delete<ThrowOnError extends boolean = true>(options: Options<DeleteData, ThrowOnError>): import("./client").RequestResult<DeleteResponses, DeleteErrors, ThrowOnError, "fields">;
33
- static listQueue<ThrowOnError extends boolean = true>(options?: Options<ListQueueData, ThrowOnError>): import("./client").RequestResult<ListQueueResponses, ListQueueErrors, ThrowOnError, "fields">;
32
+ static delete<ThrowOnError extends boolean = true>(options: Options<DeleteData, ThrowOnError>): RequestResult<DeleteResponses, DeleteErrors, ThrowOnError>;
33
+ static listQueue<ThrowOnError extends boolean = true>(options?: Options<ListQueueData, ThrowOnError>): RequestResult<ListQueueResponses, ListQueueErrors, ThrowOnError>;
34
34
  /**
35
35
  * Peek an item from the queue
36
36
  */
37
- static peekItem<ThrowOnError extends boolean = true>(options?: Options<PeekItemData, ThrowOnError>): import("./client").RequestResult<PeekItemResponses, PeekItemErrors, ThrowOnError, "fields">;
37
+ static peekItem<ThrowOnError extends boolean = true>(options?: Options<PeekItemData, ThrowOnError>): RequestResult<PeekItemResponses, PeekItemErrors, ThrowOnError>;
38
38
  /**
39
39
  * Takes an item off the queue, removes the schedule date and puts it back
40
40
  */
41
- static process<ThrowOnError extends boolean = true>(options: Options<ProcessData, ThrowOnError>): import("./client").RequestResult<ProcessResponses, ProcessErrors, ThrowOnError, "fields">;
41
+ static process<ThrowOnError extends boolean = true>(options: Options<ProcessData, ThrowOnError>): RequestResult<ProcessResponses, ProcessErrors, ThrowOnError>;
42
42
  }
@@ -56,7 +56,8 @@ export type PipelineRunRejected = {
56
56
  export declare enum PipelineRunRejectedReason {
57
57
  NOT_FOUND = "NotFound",
58
58
  ALREADY_RUNNING = "AlreadyRunning",
59
- INVALID = "Invalid"
59
+ INVALID = "Invalid",
60
+ NOT_WAITING = "NotWaiting"
60
61
  }
61
62
  export type PipelineRunRequest = {
62
63
  processor: string;
@@ -4,6 +4,7 @@ export var PipelineRunRejectedReason;
4
4
  PipelineRunRejectedReason["NOT_FOUND"] = "NotFound";
5
5
  PipelineRunRejectedReason["ALREADY_RUNNING"] = "AlreadyRunning";
6
6
  PipelineRunRejectedReason["INVALID"] = "Invalid";
7
+ PipelineRunRejectedReason["NOT_WAITING"] = "NotWaiting";
7
8
  })(PipelineRunRejectedReason || (PipelineRunRejectedReason = {}));
8
9
  export var PipelineRunState;
9
10
  (function (PipelineRunState) {
package/dist/index.js CHANGED
@@ -6,7 +6,15 @@ import './api/index.js';
6
6
  import { manifests as modals } from './pipeline/modal/manifest.js';
7
7
  import { manifests as pipelines } from './pipeline/workspace/manifest.js';
8
8
  import { manifests as localizations } from './lang/manifest.js';
9
+ import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth';
10
+ import { client } from './api/client.gen.js';
9
11
  export * from './exports.js';
10
- export const onInit = (_host, extensions) => {
12
+ export const onInit = async (host, extensions) => {
11
13
  extensions.registerMany([...modals, ...pipelines, ...localizations]);
14
+ const authContext = await host.getContext(UMB_AUTH_CONTEXT);
15
+ if (!authContext) {
16
+ console.warn('UMB_AUTH_CONTEXT not available — extension API client will not be authenticated');
17
+ return;
18
+ }
19
+ authContext.configureClient(client);
12
20
  };
@@ -24,6 +24,8 @@ declare const _default: {
24
24
  messageWaiting: string;
25
25
  headlineScheduled: string;
26
26
  messageScheduled: string;
27
+ checked: string;
28
+ tryAgain: string;
27
29
  status: string;
28
30
  startedBy: string;
29
31
  queued: string;
@@ -38,6 +40,11 @@ declare const _default: {
38
40
  stateCompleted: string;
39
41
  stateFailed: string;
40
42
  stateCancelled: string;
43
+ stalled: string;
44
+ clear: string;
45
+ clearHeadline: string;
46
+ clearConfirm: string;
47
+ clearConfirmLabel: string;
41
48
  };
42
49
  jumooProcBackground: {
43
50
  completed: string;
@@ -15,15 +15,17 @@ export default {
15
15
  },
16
16
  jumooProcConflict: {
17
17
  headline: 'Already in progress',
18
- message: 'Another process is already in progress for this target. Wait for it to finish, or cancel it, then try again.',
18
+ message: 'Another process is already in progress for this target. Try again once it has finished.',
19
19
  headlineRunning: 'Already running',
20
- messageRunning: 'Another process is already running for this target. Wait for it to finish, or cancel it, then try again.',
20
+ messageRunning: 'Another process is already running for this target. Try again once it has finished.',
21
21
  headlineQueued: 'Already queued',
22
- messageQueued: 'Another process for this target is queued and will start shortly. Wait for it to finish, or cancel it, then try again.',
22
+ messageQueued: 'Another process for this target is queued and will start shortly. Try again once it has finished.',
23
23
  headlineWaiting: 'Waiting to continue',
24
- messageWaiting: 'Another process for this target is paused and waiting to continue. Finish or cancel it, then try again.',
24
+ messageWaiting: 'Another process for this target is paused, waiting for whoever started it to continue. Try again once it has been finished or cancelled.',
25
25
  headlineScheduled: 'Already scheduled',
26
- messageScheduled: 'Another process for this target is scheduled. Cancel it, or wait for it to run, then try again.',
26
+ messageScheduled: 'Another process for this target is scheduled. Try again once it has run.',
27
+ checked: 'Checked',
28
+ tryAgain: 'Try again',
27
29
  status: 'Status',
28
30
  startedBy: 'Started by',
29
31
  queued: 'Queued',
@@ -38,6 +40,11 @@ export default {
38
40
  stateCompleted: 'Completed',
39
41
  stateFailed: 'Failed',
40
42
  stateCancelled: 'Cancelled',
43
+ stalled: "It hasn't moved for a while, so it has probably stopped (a closed browser, or an error). You can clear it and start again.",
44
+ clear: 'Clear it',
45
+ clearHeadline: 'Clear the other process?',
46
+ clearConfirm: 'This removes the other process so this one can start. If it is still working, it stops part way through.',
47
+ clearConfirmLabel: 'Clear and start',
41
48
  },
42
49
  jumooProcBackground: {
43
50
  completed: 'This process has completed in the background',
@@ -22,6 +22,12 @@ export declare class PipelineContext extends UmbControllerBase {
22
22
  private isMessage;
23
23
  private isState;
24
24
  createPipeline(processor: string, strategy: string, options: ProcessingOptions | undefined): Promise<void>;
25
+ /**
26
+ * @description clears the pipeline holding the key, so a create can be tried again. For a
27
+ * holder that has stopped moving - the server only lets go of a browser-driven run once it
28
+ * has been idle for the concurrency key idle timeout.
29
+ */
30
+ clearConflictHolder(): Promise<void>;
25
31
  loadPipeline(id: string): Promise<void>;
26
32
  getPipeline(id: string): Promise<import("@jumoo/processing").Pipeline>;
27
33
  fetchPipeline(id: string): Promise<import("@jumoo/processing").Pipeline>;
@@ -92,14 +92,27 @@ export class PipelineContext extends UmbControllerBase {
92
92
  return message !== undefined;
93
93
  }
94
94
  async createPipeline(processor, strategy, options) {
95
- __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(undefined);
95
+ // a retry keeps the current conflict showing until there's a new answer.
96
96
  const { data, error } = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").tryCreate(processor, strategy, options);
97
97
  if (error) {
98
98
  await __classPrivateFieldGet(this, _PipelineContext_instances, "m", _PipelineContext_setConflict).call(this, error);
99
99
  return;
100
100
  }
101
+ __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(undefined);
101
102
  __classPrivateFieldGet(this, _PipelineContext_pipeline, "f").setValue(data);
102
103
  }
104
+ /**
105
+ * @description clears the pipeline holding the key, so a create can be tried again. For a
106
+ * holder that has stopped moving - the server only lets go of a browser-driven run once it
107
+ * has been idle for the concurrency key idle timeout.
108
+ */
109
+ async clearConflictHolder() {
110
+ const conflict = __classPrivateFieldGet(this, _PipelineContext_conflict, "f").value;
111
+ if (!conflict)
112
+ return;
113
+ await __classPrivateFieldGet(this, _PipelineContext_repository, "f").clear(conflict.runningPipelineId);
114
+ __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(undefined);
115
+ }
103
116
  async loadPipeline(id) {
104
117
  const pipeline = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").Get(id);
105
118
  if (!pipeline)
@@ -285,10 +298,8 @@ async function _PipelineContext_setConflict(error) {
285
298
  const conflict = getPipelineConflict(error);
286
299
  if (!conflict)
287
300
  return false;
288
- __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(conflict);
289
301
  const holder = await __classPrivateFieldGet(this, _PipelineContext_repository, "f").getRunStatus(conflict.runningPipelineId);
290
- if (holder)
291
- __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue({ ...conflict, holder });
302
+ __classPrivateFieldGet(this, _PipelineContext_conflict, "f").setValue(holder ? { ...conflict, holder } : conflict);
292
303
  return true;
293
304
  };
294
305
  export default PipelineContext;
@@ -13,6 +13,7 @@ import { ProcessingOptions } from '@jumoo/processing';
13
13
  * process is already running for the same target (detail is the PipelineConflict).
14
14
  */
15
15
  export declare class JumooPipelineElement extends UmbLitElement {
16
+ #private;
16
17
  private context?;
17
18
  /**
18
19
  * @description The processor to use for the pipeline
@@ -38,6 +39,12 @@ export declare class JumooPipelineElement extends UmbLitElement {
38
39
  private message;
39
40
  private backgroundState;
40
41
  private conflict;
42
+ /**
43
+ * @description when the conflict was last checked. The panel doesn't update by itself, so it
44
+ * shows how old its answer is.
45
+ */
46
+ private conflictCheckedAt;
47
+ private retrying;
41
48
  constructor();
42
49
  connectedCallback(): void;
43
50
  private process;
@@ -61,6 +68,20 @@ export declare class JumooPipelineElement extends UmbLitElement {
61
68
  private onLastAction;
62
69
  render(): import("lit-html").TemplateResult<1>;
63
70
  private renderConflict;
71
+ /**
72
+ * @description only a conflict from creating this pipeline can be tried again from here -
73
+ * one from an existing pipeline has nothing to recreate.
74
+ * @returns true when the panel should offer to try again.
75
+ */
76
+ private canRetry;
77
+ /**
78
+ * @description a running holder that has stopped moving can be cleared, but only when the
79
+ * conflict came from creating this pipeline - that's the one we know how to try again.
80
+ * The holder is only there when the user can see it (its owner, or an admin).
81
+ * @param holder the holder's status.
82
+ * @returns true when the panel should offer to clear it.
83
+ */
84
+ private canClear;
64
85
  /**
65
86
  * @description the time worth showing for the holder: when it was queued, when it last
66
87
  * moved, how long it has been paused, or when it is due.
@@ -4,8 +4,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _JumooPipelineElement_instances, _JumooPipelineElement_onRetryConflict, _JumooPipelineElement_onClearConflict;
7
13
  import { css, customElement, html, nothing, property, state, } from '@umbraco-cms/backoffice/external/lit';
8
14
  import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
15
+ import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
9
16
  import { PipelineStatus, JUMOO_PROCESSING_CONTEXT, } from '@jumoo/processing';
10
17
  import { PipelineRunState } from '../api/index.js';
11
18
  /**
@@ -25,6 +32,12 @@ function conflictSuffix(status) {
25
32
  return '';
26
33
  }
27
34
  }
35
+ /**
36
+ * @description how long a running holder goes without moving before the conflict panel offers
37
+ * to clear it. A browser-driven run saves after every step, so one this quiet has most likely
38
+ * lost its browser.
39
+ */
40
+ const CLEAR_AFTER_IDLE_MS = 5 * 60 * 1000;
28
41
  /**
29
42
  * @property {string} processor - the processor to use for the pipeline
30
43
  * @property {string} strategy - the strategy to use for the pipeline
@@ -40,10 +53,12 @@ function conflictSuffix(status) {
40
53
  let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
41
54
  constructor() {
42
55
  super();
56
+ _JumooPipelineElement_instances.add(this);
43
57
  /**
44
58
  * @description - show debug information
45
59
  */
46
60
  this.debug = false;
61
+ this.retrying = false;
47
62
  this.consumeContext(JUMOO_PROCESSING_CONTEXT, (context) => {
48
63
  if (!context)
49
64
  return;
@@ -96,6 +111,7 @@ let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
96
111
  this.observe(this.context.conflict, (conflict) => {
97
112
  const isNew = conflict && !this.conflict;
98
113
  this.conflict = conflict;
114
+ this.conflictCheckedAt = conflict ? new Date() : undefined;
99
115
  if (isNew) {
100
116
  this.dispatchEvent(new CustomEvent('pipeline-conflict', {
101
117
  bubbles: true,
@@ -209,11 +225,69 @@ let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
209
225
  >
210
226
  </dt>
211
227
  <dd>${Math.round(holder.progress.percentage)}%</dd>`
228
+ : nothing}
229
+ ${this.conflictCheckedAt
230
+ ? html `<dt>
231
+ <umb-localize key="jumooProcConflict_checked"
232
+ >Checked</umb-localize
233
+ >
234
+ </dt>
235
+ <dd>
236
+ ${this.localize.date(this.conflictCheckedAt, {
237
+ timeStyle: 'medium',
238
+ })}
239
+ </dd>`
212
240
  : nothing}
213
241
  </dl>`
242
+ : nothing}
243
+ ${holder && this.canClear(holder)
244
+ ? html `<p>${this.localize.term('jumooProcConflict_stalled')}</p>`
245
+ : nothing}
246
+ ${this.canRetry()
247
+ ? html `<div class="actions">
248
+ <uui-button
249
+ look="secondary"
250
+ label=${this.localize.term('jumooProcConflict_tryAgain')}
251
+ .state=${this.retrying ? 'waiting' : undefined}
252
+ ?disabled=${this.retrying}
253
+ @click=${__classPrivateFieldGet(this, _JumooPipelineElement_instances, "m", _JumooPipelineElement_onRetryConflict)}></uui-button>
254
+ ${holder && this.canClear(holder)
255
+ ? html `<uui-button
256
+ look="primary"
257
+ color="warning"
258
+ label=${this.localize.term('jumooProcConflict_clear')}
259
+ ?disabled=${this.retrying}
260
+ @click=${__classPrivateFieldGet(this, _JumooPipelineElement_instances, "m", _JumooPipelineElement_onClearConflict)}></uui-button>`
261
+ : nothing}
262
+ </div>`
214
263
  : nothing}
215
264
  </div>`;
216
265
  }
266
+ /**
267
+ * @description only a conflict from creating this pipeline can be tried again from here -
268
+ * one from an existing pipeline has nothing to recreate.
269
+ * @returns true when the panel should offer to try again.
270
+ */
271
+ canRetry() {
272
+ return !this._pipelineId && !!this.processor && !!this.strategy;
273
+ }
274
+ /**
275
+ * @description a running holder that has stopped moving can be cleared, but only when the
276
+ * conflict came from creating this pipeline - that's the one we know how to try again.
277
+ * The holder is only there when the user can see it (its owner, or an admin).
278
+ * @param holder the holder's status.
279
+ * @returns true when the panel should offer to clear it.
280
+ */
281
+ canClear(holder) {
282
+ if (!this.canRetry())
283
+ return false;
284
+ if (holder.status !== PipelineRunState.RUNNING)
285
+ return false;
286
+ const lastActivity = holder.modified ?? holder.created;
287
+ if (!lastActivity)
288
+ return false;
289
+ return Date.now() - new Date(lastActivity).getTime() > CLEAR_AFTER_IDLE_MS;
290
+ }
217
291
  /**
218
292
  * @description the time worth showing for the holder: when it was queued, when it last
219
293
  * moved, how long it has been paused, or when it is due.
@@ -307,6 +381,43 @@ let JumooPipelineElement = class JumooPipelineElement extends UmbLitElement {
307
381
  `;
308
382
  }
309
383
  };
384
+ _JumooPipelineElement_instances = new WeakSet();
385
+ _JumooPipelineElement_onRetryConflict =
386
+ /**
387
+ * @description tries the create again: starts if the other process has gone, otherwise the
388
+ * panel redraws with its latest status (which may now offer to clear it).
389
+ */
390
+ async function _JumooPipelineElement_onRetryConflict() {
391
+ if (!this.processor || !this.strategy)
392
+ return;
393
+ this.retrying = true;
394
+ try {
395
+ await this.context?.createPipeline(this.processor, this.strategy, this.setup);
396
+ }
397
+ finally {
398
+ this.retrying = false;
399
+ }
400
+ // an unchanged answer doesn't reach the conflict observer, so stamp it here too.
401
+ if (this.conflict)
402
+ this.conflictCheckedAt = new Date();
403
+ };
404
+ _JumooPipelineElement_onClearConflict = async function _JumooPipelineElement_onClearConflict() {
405
+ try {
406
+ await umbConfirmModal(this, {
407
+ headline: this.localize.term('jumooProcConflict_clearHeadline'),
408
+ content: this.localize.term('jumooProcConflict_clearConfirm'),
409
+ color: 'danger',
410
+ confirmLabel: this.localize.term('jumooProcConflict_clearConfirmLabel'),
411
+ });
412
+ }
413
+ catch {
414
+ return; // closed the dialog.
415
+ }
416
+ if (!this.processor || !this.strategy)
417
+ return;
418
+ await this.context?.clearConflictHolder();
419
+ await this.context?.createPipeline(this.processor, this.strategy, this.setup);
420
+ };
310
421
  JumooPipelineElement.styles = css `
311
422
  .wrapper,
312
423
  umb-extension-slot {
@@ -346,6 +457,11 @@ JumooPipelineElement.styles = css `
346
457
  .conflict dd {
347
458
  margin: 0;
348
459
  }
460
+
461
+ .conflict .actions {
462
+ display: flex;
463
+ gap: var(--uui-size-space-3);
464
+ }
349
465
  `;
350
466
  __decorate([
351
467
  property({ type: String })
@@ -383,6 +499,12 @@ __decorate([
383
499
  __decorate([
384
500
  state()
385
501
  ], JumooPipelineElement.prototype, "conflict", void 0);
502
+ __decorate([
503
+ state()
504
+ ], JumooPipelineElement.prototype, "conflictCheckedAt", void 0);
505
+ __decorate([
506
+ state()
507
+ ], JumooPipelineElement.prototype, "retrying", void 0);
386
508
  JumooPipelineElement = __decorate([
387
509
  customElement('jumoo-pipeline')
388
510
  ], JumooPipelineElement);
@@ -24,7 +24,9 @@ export class QueueContext extends UmbControllerBase {
24
24
  }
25
25
  async loadQueue() {
26
26
  const queue = await __classPrivateFieldGet(this, _QueueContext_repository, "f").list();
27
- __classPrivateFieldGet(this, _QueueContext_queue, "f").setValue(queue);
27
+ // undefined means the request failed, so keep the last list rather than clearing it.
28
+ if (queue)
29
+ __classPrivateFieldGet(this, _QueueContext_queue, "f").setValue(queue);
28
30
  return queue;
29
31
  }
30
32
  async process(key) {
@@ -1,32 +1,33 @@
1
1
  import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
2
+ import { tryExecute } from '@umbraco-cms/backoffice/resources';
2
3
  import { QueuesService } from '../api';
3
4
  export class QueueRepository extends UmbControllerBase {
4
5
  constructor(host) {
5
6
  super(host);
6
7
  }
7
8
  async list() {
8
- return (await QueuesService.listQueue()).data;
9
+ return (await tryExecute(this, QueuesService.listQueue())).data;
9
10
  }
10
11
  async peek(key) {
11
- return (await QueuesService.peekItem({
12
+ return (await tryExecute(this, QueuesService.peekItem({
12
13
  query: {
13
14
  key: key,
14
15
  },
15
- })).data;
16
+ }))).data;
16
17
  }
17
18
  async delete(key) {
18
- return (await QueuesService.delete({
19
+ return (await tryExecute(this, QueuesService.delete({
19
20
  path: {
20
21
  key: key,
21
22
  },
22
- })).data;
23
+ }))).data;
23
24
  }
24
25
  async process(key) {
25
- return (await QueuesService.process({
26
+ return (await tryExecute(this, QueuesService.process({
26
27
  path: {
27
28
  key: key,
28
29
  },
29
- })).data;
30
+ }))).data;
30
31
  }
31
32
  }
32
33
  export default QueueRepository;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jumoo/processing",
3
3
  "licence": "custom",
4
- "version": "17.5.1",
4
+ "version": "17.5.3",
5
5
  "type": "module",
6
6
  "description": "Jumoo processing library",
7
7
  "exports": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@eslint/js": "^10.0.1",
41
- "@hey-api/openapi-ts": "^0.95.0",
41
+ "@hey-api/openapi-ts": "^0.99.0",
42
42
  "@microsoft/signalr": "^10.0.0",
43
43
  "@umbraco-cms/backoffice": "^17.3.0",
44
44
  "eslint": "^10.13.0",
@@ -46,7 +46,7 @@
46
46
  "lit": "^3.3.2",
47
47
  "prettier": "^3.9.10",
48
48
  "typescript": "^6.0.3",
49
- "typescript-eslint": "^8.72.0",
49
+ "typescript-eslint": "^8.72.1",
50
50
  "vite": "^8.3.5",
51
51
  "vite-plugin-dts": "^5.1.2"
52
52
  },
package/dist/hey-api.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { CreateClientConfig } from './api/client.gen';
2
- /**
3
- * Pre-configure the generated client by copying the Umbraco HTTP client's config.
4
- *
5
- * Called automatically by the generated client during initialization (via runtimeConfigPath).
6
- * Inherits baseUrl, credentials, auth, and headers from umbHttpClient — which is already
7
- * configured by the backoffice before extensions load.
8
- *
9
- * @see https://heyapi.dev/openapi-ts/clients/fetch#configuration
10
- */
11
- export declare const createClientConfig: CreateClientConfig;
package/dist/hey-api.js DELETED
@@ -1,14 +0,0 @@
1
- import { umbHttpClient } from '@umbraco-cms/backoffice/http-client';
2
- /**
3
- * Pre-configure the generated client by copying the Umbraco HTTP client's config.
4
- *
5
- * Called automatically by the generated client during initialization (via runtimeConfigPath).
6
- * Inherits baseUrl, credentials, auth, and headers from umbHttpClient — which is already
7
- * configured by the backoffice before extensions load.
8
- *
9
- * @see https://heyapi.dev/openapi-ts/clients/fetch#configuration
10
- */
11
- export const createClientConfig = (config) => ({
12
- ...config,
13
- ...umbHttpClient.getConfig(),
14
- });