@orieljs/support 0.1.0-alpha.5 → 0.1.0-alpha.7

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/NOTICE CHANGED
@@ -7,3 +7,10 @@ This product includes software developed by the Oriel project
7
7
  Oriel is licensed under the Apache License, Version 2.0 (see LICENSE).
8
8
  The Oriel name and logo are not covered by that license; see TRADEMARKS.md
9
9
  (https://github.com/orieljs/framework/blob/main/TRADEMARKS.md).
10
+
11
+ @orieljs/support (and @orieljs/framework, which bundles it) includes transliteration data from
12
+ voku/portable-ascii (https://github.com/voku/portable-ascii), Copyright (C) 2019 Lars Moelleken, MIT License.
13
+
14
+ @orieljs/notifications (and @orieljs/framework, which bundles it) includes the HTML and CSS of
15
+ Laravel's default notification mail (laravel/framework, https://github.com/laravel/framework),
16
+ Copyright (c) Taylor Otwell, MIT License.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @orieljs/support
2
+
3
+ The helpers the rest of Oriel is built on: `Str`, `Arr`, service providers, facades and global helpers, as Laravel's `Illuminate\Support`. It is part of `@orieljs/framework`, which every Oriel app already installs, and is re-exported from it. In an app, import it from `@orieljs/framework`; `@orieljs/support` is also published on its own.
4
+
5
+ ```bash
6
+ npm install @orieljs/framework
7
+ ```
8
+
9
+ ```ts title="app/Support/posts.ts"
10
+ import { Str, collect } from '@orieljs/framework'
11
+ import type { Post } from '../Models/Post'
12
+
13
+ export function card(post: Post) {
14
+ return {
15
+ title: Str.of(post.title).trim().title().toString(),
16
+ excerpt: Str.limit(post.body, 120),
17
+ url: `/posts/${Str.slug(post.title)}`,
18
+ }
19
+ }
20
+
21
+ export function authorIds(posts: Post[]): number[] {
22
+ return collect(posts).pluck('author_id').unique().all()
23
+ }
24
+ ```
25
+
26
+ `Str` has Laravel's string helpers (`slug()`, `limit()`, `plural()`, `uuid()`, …), and `Str.of()` chains them. `Arr` reads and writes nested values by dotted key (`get()`, `set()`, `has()`), flattens them with `dot()` and picks keys with `only()`. `ServiceProvider` and `facade()` are the base of every component, and the helpers are `app()`, `config()`, `collect()`, `now()`, the async `retry()`, `tap()`, `value()` and `__()`.
27
+
28
+ Documentation: https://orieljs.vercel.app/docs/helpers
29
+
30
+ Status: early alpha. APIs will change.
31
+
32
+ ## License
33
+
34
+ Oriel is open-source software licensed under the Apache License 2.0 (Apache-2.0; see `LICENSE` and `NOTICE`). The Oriel name and logo are trademarks; see `TRADEMARKS.md`.
35
+
36
+ Website: https://orieljs.vercel.app
package/TRADEMARKS.md ADDED
@@ -0,0 +1,33 @@
1
+ # Oriel trademark policy
2
+
3
+ The Oriel code is open source under the Apache License 2.0. The **Oriel name and logo** are not: the license covers
4
+ the code only (section 6 of the license says so), and the name and logo stay with the project. This page explains
5
+ what you can and can't do with them. The goal is simple: people should always be able to tell what is the real Oriel
6
+ and what isn't.
7
+
8
+ ## You can, without asking
9
+
10
+ - Use, change, ship and sell the code, as the license allows.
11
+ - Say that your app or package is "built with Oriel", "for Oriel" or "compatible with Oriel".
12
+ - Name a package `oriel-<something>` or `<something>-for-oriel` when it works with Oriel, as long as it is clear that
13
+ it is not official (for example, don't publish it under the `@orieljs` npm scope).
14
+ - Use the name and logo to write about Oriel, teach it, or link to it, in articles, talks, videos and courses.
15
+ - Use the unmodified logo to point to the project, as it is (no recolouring, cropping or
16
+ distortion).
17
+
18
+ ## You can't, without written permission
19
+
20
+ - Call a fork, a modified copy or a competing product "Oriel", or anything likely to be confused with it.
21
+ - Use the name or logo as the name, logo or domain of your own product, company or service.
22
+ - Suggest that the Oriel project made, endorses or supports your work when it doesn't.
23
+ - Sell merchandise with the name or logo.
24
+
25
+ ## Forks
26
+
27
+ Forks are welcome. Please give yours a different name and logo, keep the `LICENSE` and `NOTICE` files, and say that
28
+ it is based on Oriel.
29
+
30
+ ## Questions
31
+
32
+ Open an issue at https://github.com/orieljs/framework or email meeeet.dev@gmail.com. If you're unsure whether a use
33
+ is fine, ask; the answer is usually yes.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,72 @@
1
- import { ServiceProvider as ServiceProvider$1, Application, Abstract, ClassRegistry as ClassRegistry$1, Class, ConfigRepository } from '@orieljs/contracts';
1
+ import { Collection } from '@orieljs/collections';
2
2
  export { collect } from '@orieljs/collections';
3
+ import { ServiceProvider as ServiceProvider$1, Application, Abstract, ClassRegistry as ClassRegistry$1, Class, ConfigRepository } from '@orieljs/contracts';
4
+
5
+ /**
6
+ * Laravel's Stringable: a string with Str's helpers as chainable methods, each returning a new Stringable.
7
+ * `Str.of(' Café ').trim().slug().toString()` is 'cafe'; `request().string('q')` returns one. It prints as its string.
8
+ */
9
+ declare class Stringable {
10
+ #private;
11
+ constructor(value?: string);
12
+ after(search: string): Stringable;
13
+ afterLast(search: string): Stringable;
14
+ append(...values: string[]): Stringable;
15
+ ascii(): Stringable;
16
+ before(search: string): Stringable;
17
+ beforeLast(search: string): Stringable;
18
+ between(from: string, to: string): Stringable;
19
+ camel(): Stringable;
20
+ contains(needles: string | string[]): boolean;
21
+ endsWith(needles: string | string[]): boolean;
22
+ /** The same string as `value` (a string or another Stringable). */
23
+ exactly(value: string | Stringable): boolean;
24
+ /** The parts between the delimiters, as a Collection (PHP's explode()). */
25
+ explode(delimiter: string): Collection<string>;
26
+ finish(cap: string): Stringable;
27
+ /** Wildcard match, as Str.is(): `*` matches anything. */
28
+ is(pattern: string): boolean;
29
+ isEmpty(): boolean;
30
+ isNotEmpty(): boolean;
31
+ kebab(): Stringable;
32
+ lcfirst(): Stringable;
33
+ /** The number of characters (code points, as PHP's mb_strlen()). */
34
+ length(): number;
35
+ limit(limit?: number, end?: string): Stringable;
36
+ lower(): Stringable;
37
+ /** Strips whitespace and invisible characters from the start, or the characters given. */
38
+ ltrim(characters?: string): Stringable;
39
+ plural(count?: number): Stringable;
40
+ prepend(...values: string[]): Stringable;
41
+ /** Replaces every occurrence of the search string (or of each of several) with `replace`. */
42
+ replace(search: string | string[], replace: string): Stringable;
43
+ /** Strips whitespace and invisible characters from the end, or the characters given. */
44
+ rtrim(characters?: string): Stringable;
45
+ singular(): Stringable;
46
+ slug(separator?: string): Stringable;
47
+ snake(delimiter?: string): Stringable;
48
+ start(prefix: string): Stringable;
49
+ startsWith(needles: string | string[]): boolean;
50
+ studly(): Stringable;
51
+ title(): Stringable;
52
+ /** PHP's filter_var(FILTER_VALIDATE_BOOLEAN): '1', 'true', 'on' and 'yes' (any case, trimmed) are true. */
53
+ toBoolean(): boolean;
54
+ /** PHP's floatval(): the leading number, else 0. */
55
+ toFloat(): number;
56
+ /** PHP's intval(): the leading digits, else 0. */
57
+ toInteger(): number;
58
+ toJSON(): string;
59
+ toString(): string;
60
+ /** Strips whitespace and invisible characters from both ends (Laravel's Str::trim()), or the characters given. */
61
+ trim(characters?: string): Stringable;
62
+ ucfirst(): Stringable;
63
+ upper(): Stringable;
64
+ value(): string;
65
+ }
3
66
 
4
67
  declare const Str: {
68
+ /** Laravel's Str::of(): the value as a Stringable, for chaining: Str.of(title).trim().slug(). */
69
+ of: (value?: unknown) => Stringable;
5
70
  ucfirst: (v: string) => string;
6
71
  lcfirst: (v: string) => string;
7
72
  studly: (v: string) => string;
@@ -9,11 +74,31 @@ declare const Str: {
9
74
  snake: (v: string, delimiter?: string) => string;
10
75
  kebab: (v: string) => string;
11
76
  title: (v: string) => string;
12
- slug: (v: string, separator?: string) => string;
77
+ /** Laravel's Str::ascii(): the value in plain ASCII ('Café' → 'Cafe', 'Ελληνικά' → 'Ellinika'), as for English. */
78
+ ascii: (v: string) => string;
79
+ /**
80
+ * Laravel's Str::slug(): transliterated to ASCII first (unless `language` is null), '@' read as 'at', then lower-cased
81
+ * letters and digits joined by the separator: 'Café crème' → 'cafe-creme'. What has no ASCII form is dropped.
82
+ */
83
+ slug: (title: string, separator?: string, language?: "en" | null, dictionary?: Readonly<Record<string, string>>) => string;
13
84
  plural: (v: string, count?: number) => string;
14
85
  singular: (v: string) => string;
15
86
  random: (length?: number) => string;
16
87
  uuid: () => `${string}-${string}-${string}-${string}-${string}`;
88
+ /**
89
+ * A version 7 UUID (RFC 9562): the time in milliseconds first, so ids from later milliseconds sort after earlier ones
90
+ * (within one millisecond the order is random). Throws a TypeError for a time before 1970, after 10889 or invalid.
91
+ */
92
+ uuid7: (time?: Date) => string;
93
+ /**
94
+ * A ULID: 26 upper-case Crockford characters, ten for the time in milliseconds and sixteen random, so ids from later
95
+ * milliseconds sort after earlier ones. Throws a TypeError for a time before 1970, after 10889 or invalid.
96
+ */
97
+ ulid: (time?: Date) => string;
98
+ /** Laravel's Str::isUuid(): five groups of hex digits, any version. */
99
+ isUuid: (value: unknown) => value is string;
100
+ /** Laravel's Str::isUlid(): 26 Crockford characters in either case, the first at most 7. */
101
+ isUlid: (value: unknown) => value is string;
17
102
  /** Wildcard match: `*` matches anything; everything else is literal. */
18
103
  is: (pattern: string, value: string) => boolean;
19
104
  startsWith: (v: string, needles: string | string[]) => boolean;
@@ -149,4 +234,4 @@ declare namespace fileType {
149
234
  export { fileType_AVIF as AVIF, fileType_BINARY_AND_MARKUP_TYPES as BINARY_AND_MARKUP_TYPES, fileType_BMP as BMP, type fileType_DetectedType as DetectedType, fileType_EMPTY as EMPTY, fileType_GIF as GIF, fileType_HTML as HTML, fileType_JPEG as JPEG, fileType_PDF as PDF, fileType_PNG as PNG, fileType_RASTER_IMAGES as RASTER_IMAGES, fileType_SNIFF_BYTES as SNIFF_BYTES, fileType_SVG as SVG, fileType_TEXT as TEXT, fileType_UNKNOWN as UNKNOWN, fileType_WEBP as WEBP, fileType_XML as XML, fileType_detectFileType as detectFileType };
150
235
  }
151
236
 
152
- export { Arr, ClassRegistry, type Facade, type FacadeStatics, fileType as FileType, ServiceProvider, Str, __, app, config, facade, now, retry, tap, value };
237
+ export { Arr, ClassRegistry, type Facade, type FacadeStatics, fileType as FileType, ServiceProvider, Str, Stringable, __, app, config, facade, now, retry, tap, value };