generated from renoki-co/laravel-package-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
2,419 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
- package-ecosystem: composer | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 10 | ||
versioning-strategy: increase | ||
- package-ecosystem: github-actions | ||
groups: | ||
all: | ||
patterns: ["*"] | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 100 | ||
versioning-strategy: auto | ||
rebase-strategy: auto | ||
labels: | ||
- dependabot:actions | ||
- auto:dependabot | ||
- dependencies | ||
|
||
- package-ecosystem: composer | ||
directory: "/" | ||
schedule: | ||
interval: weekly | ||
open-pull-requests-limit: 100 | ||
versioning-strategy: auto | ||
rebase-strategy: auto | ||
labels: | ||
- dependabot:composer | ||
- auto:dependabot | ||
- dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace RenokiCo\L1; | ||
|
||
use Saloon\Http\Connector; | ||
|
||
abstract class CloudflareConnector extends Connector | ||
{ | ||
public function __construct( | ||
protected ?string $token = null, | ||
public ?string $accountId = null, | ||
public string $apiUrl = 'https://api.cloudflare.com/client/v4', | ||
) { | ||
$this->withTokenAuth($token); | ||
} | ||
|
||
public function resolveBaseUrl(): string | ||
{ | ||
return $this->apiUrl; | ||
} | ||
|
||
protected function defaultHeaders(): array | ||
{ | ||
return [ | ||
'Content-Type' => 'application/json', | ||
'Accept' => 'application/json', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace RenokiCo\L1; | ||
|
||
use Saloon\Contracts\Response; | ||
|
||
class CloudflareD1Connector extends CloudflareConnector | ||
{ | ||
public function __construct( | ||
public ?string $database = null, | ||
protected ?string $token = null, | ||
public ?string $accountId = null, | ||
public string $apiUrl = 'https://api.cloudflare.com/client/v4', | ||
) { | ||
parent::__construct($token, $accountId, $apiUrl); | ||
} | ||
|
||
public function databaseQuery(string $query, array $params): Response | ||
{ | ||
return $this->send( | ||
new D1\Requests\D1QueryRequest($this, $this->database, $query, $params), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace RenokiCo\L1; | ||
|
||
use Saloon\Http\Request; | ||
use Saloon\Contracts\Connector; | ||
|
||
abstract class CloudflareRequest extends Request | ||
{ | ||
protected CloudflareConnector $connector; | ||
|
||
public function __construct($connector) | ||
{ | ||
$this->connector = $connector; | ||
} | ||
|
||
protected function resolveConnector(): Connector | ||
{ | ||
return $this->connector; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace RenokiCo\L1\D1; | ||
|
||
use Illuminate\Database\SQLiteConnection; | ||
use RenokiCo\L1\D1\Pdo\D1Pdo; | ||
use RenokiCo\L1\CloudflareD1Connector; | ||
|
||
class D1Connection extends SQLiteConnection | ||
{ | ||
public function __construct( | ||
protected CloudflareD1Connector $connector, | ||
protected $config = [], | ||
) { | ||
parent::__construct( | ||
new D1Pdo('sqlite::memory:', $this->connector), | ||
$config['database'] ?? '', | ||
$config['prefix'] ?? '', | ||
$config, | ||
); | ||
} | ||
|
||
protected function getDefaultSchemaGrammar() | ||
{ | ||
($grammar = new D1SchemaGrammar)->setConnection($this); | ||
|
||
return $this->withTablePrefix($grammar); | ||
} | ||
|
||
public function d1(): CloudflareD1Connector | ||
{ | ||
return $this->connector; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace RenokiCo\L1\D1; | ||
|
||
use Illuminate\Support\Str; | ||
use Illuminate\Database\Schema\Grammars\SQLiteGrammar; | ||
|
||
class D1SchemaGrammar extends SQLiteGrammar | ||
{ | ||
public function compileTableExists() | ||
{ | ||
return Str::of(parent::compileTableExists()) | ||
->replace('sqlite_master', 'sqlite_schema') | ||
->__toString(); | ||
} | ||
|
||
public function compileDropAllTables() | ||
{ | ||
return Str::of(parent::compileDropAllTables()) | ||
->replace('sqlite_master', 'sqlite_schema') | ||
->__toString(); | ||
} | ||
|
||
public function compileDropAllViews() | ||
{ | ||
return Str::of(parent::compileDropAllViews()) | ||
->replace('sqlite_master', 'sqlite_schema') | ||
->__toString(); | ||
} | ||
|
||
public function compileGetAllTables() | ||
{ | ||
return Str::of(parent::compileGetAllTables()) | ||
->replace('sqlite_master', 'sqlite_schema') | ||
->__toString(); | ||
} | ||
|
||
public function compileGetAllViews() | ||
{ | ||
return Str::of(parent::compileGetAllViews()) | ||
->replace('sqlite_master', 'sqlite_schema') | ||
->__toString(); | ||
} | ||
} |
Oops, something went wrong.